diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/nxt_application.c | 13 | ||||
-rw-r--r-- | src/nxt_application.h | 2 | ||||
-rw-r--r-- | src/nxt_conf_validation.c | 15 | ||||
-rw-r--r-- | src/nxt_main_process.c | 6 |
4 files changed, 36 insertions, 0 deletions
diff --git a/src/nxt_application.c b/src/nxt_application.c index b887c819..232f5a7e 100644 --- a/src/nxt_application.c +++ b/src/nxt_application.c @@ -297,6 +297,19 @@ nxt_app_start(nxt_task_t *task, void *data) nxt_app = nxt_app_module_load(task, lang->file); } + if (app_conf->working_directory != NULL && + app_conf->working_directory[0] != 0) + { + ret = chdir(app_conf->working_directory); + + if (nxt_slow_path(ret != 0)) { + nxt_log(task, NXT_LOG_WARN, "chdir(%s) failed %E", + app_conf->working_directory, nxt_errno); + + return NXT_ERROR; + } + } + if (nxt_slow_path(nxt_thread_mutex_create(&nxt_app_mutex) != NXT_OK)) { return NXT_ERROR; } diff --git a/src/nxt_application.h b/src/nxt_application.h index 5998e3e9..ca968299 100644 --- a/src/nxt_application.h +++ b/src/nxt_application.h @@ -57,6 +57,8 @@ struct nxt_common_app_conf_s { nxt_str_t user; nxt_str_t group; + char *working_directory; + uint32_t workers; union { diff --git a/src/nxt_conf_validation.c b/src/nxt_conf_validation.c index 5cc2569f..94371ca8 100644 --- a/src/nxt_conf_validation.c +++ b/src/nxt_conf_validation.c @@ -80,6 +80,11 @@ static nxt_conf_vldt_object_t nxt_conf_vldt_python_members[] = { NULL, NULL }, + { nxt_string("working_directory"), + NXT_CONF_STRING, + NULL, + NULL }, + { nxt_string("path"), NXT_CONF_STRING, NULL, @@ -115,6 +120,11 @@ static nxt_conf_vldt_object_t nxt_conf_vldt_php_members[] = { NULL, NULL }, + { nxt_string("working_directory"), + NXT_CONF_STRING, + NULL, + NULL }, + { nxt_string("root"), NXT_CONF_STRING, NULL, @@ -155,6 +165,11 @@ static nxt_conf_vldt_object_t nxt_conf_vldt_go_members[] = { NULL, NULL }, + { nxt_string("working_directory"), + NXT_CONF_STRING, + NULL, + NULL }, + { nxt_string("executable"), NXT_CONF_STRING, NULL, diff --git a/src/nxt_main_process.c b/src/nxt_main_process.c index 34fc7ea0..a7e1adb1 100644 --- a/src/nxt_main_process.c +++ b/src/nxt_main_process.c @@ -105,6 +105,12 @@ static nxt_conf_map_t nxt_common_app_conf[] = { }, { + nxt_string("working_directory"), + NXT_CONF_MAP_CSTRZ, + offsetof(nxt_common_app_conf_t, working_directory), + }, + + { nxt_string("workers"), NXT_CONF_MAP_INT32, offsetof(nxt_common_app_conf_t, workers), |