Router: allowed empty configurations.
Now it's possible to delete "listeners" and "applications" objects. This closes #187 issue on GitHub.
This commit is contained in:
@@ -1432,14 +1432,11 @@ nxt_router_conf_create(nxt_task_t *task, nxt_router_temp_conf_t *tmcf,
|
|||||||
tmcf->router_conf->threads = nxt_ncpu;
|
tmcf->router_conf->threads = nxt_ncpu;
|
||||||
}
|
}
|
||||||
|
|
||||||
applications = nxt_conf_get_path(conf, &applications_path);
|
|
||||||
if (applications == NULL) {
|
|
||||||
nxt_alert(task, "no \"applications\" block");
|
|
||||||
return NXT_ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
router = tmcf->router_conf->router;
|
router = tmcf->router_conf->router;
|
||||||
|
|
||||||
|
applications = nxt_conf_get_path(conf, &applications_path);
|
||||||
|
|
||||||
|
if (applications != NULL) {
|
||||||
next = 0;
|
next = 0;
|
||||||
|
|
||||||
for ( ;; ) {
|
for ( ;; ) {
|
||||||
@@ -1460,7 +1457,8 @@ nxt_router_conf_create(nxt_task_t *task, nxt_router_temp_conf_t *tmcf,
|
|||||||
nxt_memzero(app, sizeof(nxt_app_t));
|
nxt_memzero(app, sizeof(nxt_app_t));
|
||||||
|
|
||||||
app->name.start = nxt_pointer_to(app, sizeof(nxt_app_t));
|
app->name.start = nxt_pointer_to(app, sizeof(nxt_app_t));
|
||||||
app->conf.start = nxt_pointer_to(app, sizeof(nxt_app_t) + name.length);
|
app->conf.start = nxt_pointer_to(app, sizeof(nxt_app_t)
|
||||||
|
+ name.length);
|
||||||
|
|
||||||
p = nxt_conf_json_print(app->conf.start, application, NULL);
|
p = nxt_conf_json_print(app->conf.start, application, NULL);
|
||||||
app->conf.length = p - app->conf.start;
|
app->conf.length = p - app->conf.start;
|
||||||
@@ -1540,7 +1538,8 @@ nxt_router_conf_create(nxt_task_t *task, nxt_router_temp_conf_t *tmcf,
|
|||||||
nxt_debug(task, "application type: %V", &apcf.type);
|
nxt_debug(task, "application type: %V", &apcf.type);
|
||||||
nxt_debug(task, "application processes: %D", apcf.processes);
|
nxt_debug(task, "application processes: %D", apcf.processes);
|
||||||
nxt_debug(task, "application request timeout: %M", apcf.timeout);
|
nxt_debug(task, "application request timeout: %M", apcf.timeout);
|
||||||
nxt_debug(task, "application reschedule timeout: %M", apcf.res_timeout);
|
nxt_debug(task, "application reschedule timeout: %M",
|
||||||
|
apcf.res_timeout);
|
||||||
nxt_debug(task, "application requests: %D", apcf.requests);
|
nxt_debug(task, "application requests: %D", apcf.requests);
|
||||||
|
|
||||||
lang = nxt_app_lang_module(task->thread->runtime, &apcf.type);
|
lang = nxt_app_lang_module(task->thread->runtime, &apcf.type);
|
||||||
@@ -1604,6 +1603,7 @@ nxt_router_conf_create(nxt_task_t *task, nxt_router_temp_conf_t *tmcf,
|
|||||||
app_joint->free_app_work.task = &engine->task;
|
app_joint->free_app_work.task = &engine->task;
|
||||||
app_joint->free_app_work.obj = app_joint;
|
app_joint->free_app_work.obj = app_joint;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
routes_conf = nxt_conf_get_path(conf, &routes_path);
|
routes_conf = nxt_conf_get_path(conf, &routes_path);
|
||||||
if (nxt_fast_path(routes_conf != NULL)) {
|
if (nxt_fast_path(routes_conf != NULL)) {
|
||||||
@@ -1623,11 +1623,8 @@ nxt_router_conf_create(nxt_task_t *task, nxt_router_temp_conf_t *tmcf,
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
listeners = nxt_conf_get_path(conf, &listeners_path);
|
listeners = nxt_conf_get_path(conf, &listeners_path);
|
||||||
if (listeners == NULL) {
|
|
||||||
nxt_alert(task, "no \"listeners\" block");
|
|
||||||
return NXT_ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if (listeners != NULL) {
|
||||||
next = 0;
|
next = 0;
|
||||||
|
|
||||||
for ( ;; ) {
|
for ( ;; ) {
|
||||||
@@ -1644,7 +1641,8 @@ nxt_router_conf_create(nxt_task_t *task, nxt_router_temp_conf_t *tmcf,
|
|||||||
nxt_memzero(&lscf, sizeof(lscf));
|
nxt_memzero(&lscf, sizeof(lscf));
|
||||||
|
|
||||||
ret = nxt_conf_map_object(mp, listener, nxt_router_listener_conf,
|
ret = nxt_conf_map_object(mp, listener, nxt_router_listener_conf,
|
||||||
nxt_nitems(nxt_router_listener_conf), &lscf);
|
nxt_nitems(nxt_router_listener_conf),
|
||||||
|
&lscf);
|
||||||
if (ret != NXT_OK) {
|
if (ret != NXT_OK) {
|
||||||
nxt_alert(task, "listener map error");
|
nxt_alert(task, "listener map error");
|
||||||
goto fail;
|
goto fail;
|
||||||
@@ -1665,7 +1663,8 @@ nxt_router_conf_create(nxt_task_t *task, nxt_router_temp_conf_t *tmcf,
|
|||||||
|
|
||||||
if (http != NULL) {
|
if (http != NULL) {
|
||||||
ret = nxt_conf_map_object(mp, http, nxt_router_http_conf,
|
ret = nxt_conf_map_object(mp, http, nxt_router_http_conf,
|
||||||
nxt_nitems(nxt_router_http_conf), skcf);
|
nxt_nitems(nxt_router_http_conf),
|
||||||
|
skcf);
|
||||||
if (ret != NXT_OK) {
|
if (ret != NXT_OK) {
|
||||||
nxt_alert(task, "http map error");
|
nxt_alert(task, "http map error");
|
||||||
goto fail;
|
goto fail;
|
||||||
@@ -1673,7 +1672,6 @@ nxt_router_conf_create(nxt_task_t *task, nxt_router_temp_conf_t *tmcf,
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if (NXT_TLS)
|
#if (NXT_TLS)
|
||||||
|
|
||||||
value = nxt_conf_get_path(listener, &certificate_path);
|
value = nxt_conf_get_path(listener, &certificate_path);
|
||||||
|
|
||||||
if (value != NULL) {
|
if (value != NULL) {
|
||||||
@@ -1689,7 +1687,6 @@ nxt_router_conf_create(nxt_task_t *task, nxt_router_temp_conf_t *tmcf,
|
|||||||
|
|
||||||
nxt_queue_insert_tail(&tmcf->tls, &tls->link);
|
nxt_queue_insert_tail(&tmcf->tls, &tls->link);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
skcf->listen->handler = nxt_http_conn_init;
|
skcf->listen->handler = nxt_http_conn_init;
|
||||||
@@ -1705,6 +1702,7 @@ nxt_router_conf_create(nxt_task_t *task, nxt_router_temp_conf_t *tmcf,
|
|||||||
&lscf.application);
|
&lscf.application);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
value = nxt_conf_get_path(conf, &access_log_path);
|
value = nxt_conf_get_path(conf, &access_log_path);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user