Introducing working_directory directive for applications.
This commit is contained in:
@@ -297,6 +297,19 @@ nxt_app_start(nxt_task_t *task, void *data)
|
|||||||
nxt_app = nxt_app_module_load(task, lang->file);
|
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)) {
|
if (nxt_slow_path(nxt_thread_mutex_create(&nxt_app_mutex) != NXT_OK)) {
|
||||||
return NXT_ERROR;
|
return NXT_ERROR;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,6 +57,8 @@ struct nxt_common_app_conf_s {
|
|||||||
nxt_str_t user;
|
nxt_str_t user;
|
||||||
nxt_str_t group;
|
nxt_str_t group;
|
||||||
|
|
||||||
|
char *working_directory;
|
||||||
|
|
||||||
uint32_t workers;
|
uint32_t workers;
|
||||||
|
|
||||||
union {
|
union {
|
||||||
|
|||||||
@@ -80,6 +80,11 @@ static nxt_conf_vldt_object_t nxt_conf_vldt_python_members[] = {
|
|||||||
NULL,
|
NULL,
|
||||||
NULL },
|
NULL },
|
||||||
|
|
||||||
|
{ nxt_string("working_directory"),
|
||||||
|
NXT_CONF_STRING,
|
||||||
|
NULL,
|
||||||
|
NULL },
|
||||||
|
|
||||||
{ nxt_string("path"),
|
{ nxt_string("path"),
|
||||||
NXT_CONF_STRING,
|
NXT_CONF_STRING,
|
||||||
NULL,
|
NULL,
|
||||||
@@ -115,6 +120,11 @@ static nxt_conf_vldt_object_t nxt_conf_vldt_php_members[] = {
|
|||||||
NULL,
|
NULL,
|
||||||
NULL },
|
NULL },
|
||||||
|
|
||||||
|
{ nxt_string("working_directory"),
|
||||||
|
NXT_CONF_STRING,
|
||||||
|
NULL,
|
||||||
|
NULL },
|
||||||
|
|
||||||
{ nxt_string("root"),
|
{ nxt_string("root"),
|
||||||
NXT_CONF_STRING,
|
NXT_CONF_STRING,
|
||||||
NULL,
|
NULL,
|
||||||
@@ -155,6 +165,11 @@ static nxt_conf_vldt_object_t nxt_conf_vldt_go_members[] = {
|
|||||||
NULL,
|
NULL,
|
||||||
NULL },
|
NULL },
|
||||||
|
|
||||||
|
{ nxt_string("working_directory"),
|
||||||
|
NXT_CONF_STRING,
|
||||||
|
NULL,
|
||||||
|
NULL },
|
||||||
|
|
||||||
{ nxt_string("executable"),
|
{ nxt_string("executable"),
|
||||||
NXT_CONF_STRING,
|
NXT_CONF_STRING,
|
||||||
NULL,
|
NULL,
|
||||||
|
|||||||
@@ -104,6 +104,12 @@ static nxt_conf_map_t nxt_common_app_conf[] = {
|
|||||||
offsetof(nxt_common_app_conf_t, group),
|
offsetof(nxt_common_app_conf_t, group),
|
||||||
},
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
nxt_string("working_directory"),
|
||||||
|
NXT_CONF_MAP_CSTRZ,
|
||||||
|
offsetof(nxt_common_app_conf_t, working_directory),
|
||||||
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
nxt_string("workers"),
|
nxt_string("workers"),
|
||||||
NXT_CONF_MAP_INT32,
|
NXT_CONF_MAP_INT32,
|
||||||
|
|||||||
Reference in New Issue
Block a user