diff options
Diffstat (limited to 'src/nxt_runtime.c')
-rw-r--r-- | src/nxt_runtime.c | 65 |
1 files changed, 50 insertions, 15 deletions
diff --git a/src/nxt_runtime.c b/src/nxt_runtime.c index c7e4455e..96f801fb 100644 --- a/src/nxt_runtime.c +++ b/src/nxt_runtime.c @@ -563,6 +563,7 @@ nxt_runtime_exit(nxt_task_t *task, void *obj, void *data) #if (NXT_HAVE_UNIX_DOMAIN) { + size_t i; nxt_sockaddr_t *sa; nxt_file_name_t *name; @@ -572,6 +573,22 @@ nxt_runtime_exit(nxt_task_t *task, void *obj, void *data) name = (nxt_file_name_t *) sa->u.sockaddr_un.sun_path; (void) nxt_file_delete(name); } + + for (i = 0; i < rt->listen_sockets->nelts; i++) { + nxt_listen_socket_t *ls; + + ls = (nxt_listen_socket_t *) rt->listen_sockets->elts + i; + sa = ls->sockaddr; + + if (sa->u.sockaddr.sa_family != AF_UNIX + || sa->u.sockaddr_un.sun_path[0] == '\0') + { + continue; + } + + name = (nxt_file_name_t *) sa->u.sockaddr_un.sun_path; + (void) nxt_file_delete(name); + } } #endif } @@ -768,10 +785,10 @@ nxt_runtime_conf_init(nxt_task_t *task, nxt_runtime_t *rt) rt->group = NXT_GROUP; rt->pid = NXT_PID; rt->log = NXT_LOG; - rt->modules = NXT_MODULES; - rt->state = NXT_STATE; + rt->modules = NXT_MODULESDIR; + rt->state = NXT_STATEDIR; rt->control = NXT_CONTROL_SOCK; - rt->tmp = NXT_TMP; + rt->tmp = NXT_TMPDIR; nxt_memzero(&rt->capabilities, sizeof(nxt_capabilities_t)); @@ -889,6 +906,23 @@ nxt_runtime_conf_init(nxt_task_t *task, nxt_runtime_t *rt) "mkdir(%s) failed %E", file_name.start, nxt_errno); } + ret = nxt_file_name_create(rt->mem_pool, &file_name, "%s%sscripts/%Z", + rt->state, slash); + if (nxt_slow_path(ret != NXT_OK)) { + return NXT_ERROR; + } + + ret = mkdir((char *) file_name.start, S_IRWXU); + + if (nxt_fast_path(ret == 0 || nxt_errno == EEXIST)) { + rt->scripts.length = file_name.len; + rt->scripts.start = file_name.start; + + } else { + nxt_alert(task, "Unable to create scripts storage directory: " + "mkdir(%s) failed %E", file_name.start, nxt_errno); + } + control.length = nxt_strlen(rt->control); control.start = (u_char *) rt->control; @@ -927,9 +961,10 @@ nxt_runtime_conf_read_cmd(nxt_task_t *task, nxt_runtime_t *rt) static const char no_pid[] = "option \"--pid\" requires filename\n"; static const char no_log[] = "option \"--log\" requires filename\n"; static const char no_modules[] = - "option \"--modules\" requires directory\n"; - static const char no_state[] = "option \"--state\" requires directory\n"; - static const char no_tmp[] = "option \"--tmp\" requires directory\n"; + "option \"--modulesdir\" requires directory\n"; + static const char no_state[] = + "option \"--statedir\" requires directory\n"; + static const char no_tmp[] = "option \"--tmpdir\" requires directory\n"; static const char help[] = "\n" @@ -948,14 +983,14 @@ nxt_runtime_conf_read_cmd(nxt_task_t *task, nxt_runtime_t *rt) " --log FILE set log filename\n" " default: \"" NXT_LOG "\"\n" "\n" - " --modules DIRECTORY set modules directory name\n" - " default: \"" NXT_MODULES "\"\n" + " --modulesdir DIR set modules directory name\n" + " default: \"" NXT_MODULESDIR "\"\n" "\n" - " --state DIRECTORY set state directory name\n" - " default: \"" NXT_STATE "\"\n" + " --statedir DIR set state directory name\n" + " default: \"" NXT_STATEDIR "\"\n" "\n" - " --tmp DIRECTORY set tmp directory name\n" - " default: \"" NXT_TMP "\"\n" + " --tmpdir DIR set tmp directory name\n" + " default: \"" NXT_TMPDIR "\"\n" "\n" " --user USER set non-privileged processes to run" " as specified user\n" @@ -1038,7 +1073,7 @@ nxt_runtime_conf_read_cmd(nxt_task_t *task, nxt_runtime_t *rt) continue; } - if (nxt_strcmp(p, "--modules") == 0) { + if (nxt_strcmp(p, "--modulesdir") == 0) { if (*argv == NULL) { write(STDERR_FILENO, no_modules, nxt_length(no_modules)); return NXT_ERROR; @@ -1051,7 +1086,7 @@ nxt_runtime_conf_read_cmd(nxt_task_t *task, nxt_runtime_t *rt) continue; } - if (nxt_strcmp(p, "--state") == 0) { + if (nxt_strcmp(p, "--statedir") == 0) { if (*argv == NULL) { write(STDERR_FILENO, no_state, nxt_length(no_state)); return NXT_ERROR; @@ -1064,7 +1099,7 @@ nxt_runtime_conf_read_cmd(nxt_task_t *task, nxt_runtime_t *rt) continue; } - if (nxt_strcmp(p, "--tmp") == 0) { + if (nxt_strcmp(p, "--tmpdir") == 0) { if (*argv == NULL) { write(STDERR_FILENO, no_tmp, nxt_length(no_tmp)); return NXT_ERROR; |