summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorIgor Sysoev <igor@sysoev.ru>2017-08-26 13:37:44 +0300
committerIgor Sysoev <igor@sysoev.ru>2017-08-26 13:37:44 +0300
commit0d65c896cfa45f5e3fef05d95c9409fd68ff45c8 (patch)
tree71a420645b43a1a2d7d45fe5f35071d986e1869e /src
parent7f5b57bfb9a61ce0ba3fbc74f1775ace2d8ec6ec (diff)
downloadunit-0d65c896cfa45f5e3fef05d95c9409fd68ff45c8.tar.gz
unit-0d65c896cfa45f5e3fef05d95c9409fd68ff45c8.tar.bz2
Added configure and command line option --control.
Diffstat (limited to '')
-rw-r--r--src/nxt_controller.c16
-rw-r--r--src/nxt_listen_socket.c2
-rw-r--r--src/nxt_runtime.c61
-rw-r--r--src/nxt_runtime.h1
4 files changed, 41 insertions, 39 deletions
diff --git a/src/nxt_controller.c b/src/nxt_controller.c
index 3c9097fb..313daf00 100644
--- a/src/nxt_controller.c
+++ b/src/nxt_controller.c
@@ -147,22 +147,6 @@ nxt_runtime_controller_socket(nxt_task_t *task, nxt_runtime_t *rt)
sa = rt->controller_listen;
- if (rt->controller_listen == NULL) {
- sa = nxt_sockaddr_alloc(rt->mem_pool, sizeof(struct sockaddr_in),
- NXT_INET_ADDR_STR_LEN);
- if (sa == NULL) {
- return NXT_ERROR;
- }
-
- sa->type = SOCK_STREAM;
- sa->u.sockaddr_in.sin_family = AF_INET;
- sa->u.sockaddr_in.sin_port = htons(8443);
-
- nxt_sockaddr_text(sa);
-
- rt->controller_listen = sa;
- }
-
ls = nxt_mp_alloc(rt->mem_pool, sizeof(nxt_listen_socket_t));
if (ls == NULL) {
return NXT_ERROR;
diff --git a/src/nxt_listen_socket.c b/src/nxt_listen_socket.c
index 6fb265ea..4141c206 100644
--- a/src/nxt_listen_socket.c
+++ b/src/nxt_listen_socket.c
@@ -102,7 +102,7 @@ nxt_listen_socket_create(nxt_task_t *task, nxt_listen_socket_t *ls,
name = (nxt_file_name_t *) sa->u.sockaddr_un.sun_path;
- access = (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH);
+ access = (S_IRUSR | S_IWUSR);
if (nxt_file_set_access(name, access) != NXT_OK) {
goto fail;
diff --git a/src/nxt_runtime.c b/src/nxt_runtime.c
index f070bd94..6f66f5cd 100644
--- a/src/nxt_runtime.c
+++ b/src/nxt_runtime.c
@@ -528,6 +528,20 @@ nxt_runtime_exit(nxt_task_t *task, void *obj, void *data)
if (rt->pid_file != NULL) {
nxt_file_delete(rt->pid_file);
}
+
+#if (NXT_HAVE_UNIX_DOMAIN)
+ {
+ nxt_sockaddr_t *sa;
+ nxt_file_name_t *name;
+
+ sa = rt->controller_listen;
+
+ if (sa->u.sockaddr.sa_family == AF_UNIX) {
+ name = (nxt_file_name_t *) sa->u.sockaddr_un.sun_path;
+ (void) nxt_file_delete(name);
+ }
+ }
+#endif
}
if (!engine->event.signal_support) {
@@ -692,6 +706,8 @@ nxt_runtime_conf_init(nxt_task_t *task, nxt_runtime_t *rt)
{
nxt_int_t ret;
nxt_file_t *file;
+ nxt_str_t control;
+ nxt_sockaddr_t *sa;
nxt_file_name_str_t file_name;
const nxt_event_interface_t *interface;
@@ -704,15 +720,12 @@ nxt_runtime_conf_init(nxt_task_t *task, nxt_runtime_t *rt)
rt->pid = NXT_PID;
rt->log = NXT_LOG;
rt->modules = NXT_MODULES;
+ rt->control = NXT_CONTROL_SOCK;
if (nxt_runtime_conf_read_cmd(task, rt) != NXT_OK) {
return NXT_ERROR;
}
- if (nxt_runtime_controller_socket(task, rt) != NXT_OK) {
- return NXT_ERROR;
- }
-
if (nxt_user_cred_get(task, &rt->user_cred, rt->group) != NXT_OK) {
return NXT_ERROR;
}
@@ -749,6 +762,20 @@ nxt_runtime_conf_init(nxt_task_t *task, nxt_runtime_t *rt)
rt->modules = (char *) file_name.start;
+ control.length = nxt_strlen(rt->control);
+ control.start = (u_char *) rt->control;
+
+ sa = nxt_runtime_sockaddr_parse(task, rt->mem_pool, &control);
+ if (nxt_slow_path(sa == NULL)) {
+ return NXT_ERROR;
+ }
+
+ rt->controller_listen = sa;
+
+ if (nxt_runtime_controller_socket(task, rt) != NXT_OK) {
+ return NXT_ERROR;
+ }
+
return NXT_OK;
}
@@ -756,16 +783,16 @@ nxt_runtime_conf_init(nxt_task_t *task, nxt_runtime_t *rt)
static nxt_int_t
nxt_runtime_conf_read_cmd(nxt_task_t *task, nxt_runtime_t *rt)
{
- char *p, **argv;
- u_char *end;
- nxt_str_t addr;
- nxt_sockaddr_t *sa;
- u_char buf[1024];
+ char *p, **argv;
+ u_char *end;
+ u_char buf[1024];
static const char version[] =
"nginext version: " NXT_VERSION "\n"
"configured as ./configure" NXT_CONFIGURE_OPTIONS "\n";
+ static const char no_control[] =
+ "option \"--control\" requires socket address\n";
static const char no_user[] = "option \"--user\" requires username\n";
static const char no_group[] = "option \"--group\" requires group name\n";
static const char no_pid[] = "option \"--pid\" requires filename\n";
@@ -778,25 +805,15 @@ nxt_runtime_conf_read_cmd(nxt_task_t *task, nxt_runtime_t *rt)
while (*argv != NULL) {
p = *argv++;
- if (nxt_strcmp(p, "--listen") == 0) {
+ if (nxt_strcmp(p, "--control") == 0) {
if (*argv == NULL) {
- nxt_log(task, NXT_LOG_CRIT,
- "no argument for option \"--listen\"");
+ write(STDERR_FILENO, no_control, sizeof(no_control) - 1);
return NXT_ERROR;
}
p = *argv++;
- addr.length = nxt_strlen(p);
- addr.start = (u_char *) p;
-
- sa = nxt_runtime_sockaddr_parse(task, rt->mem_pool, &addr);
-
- if (sa == NULL) {
- return NXT_ERROR;
- }
-
- rt->controller_listen = sa;
+ rt->control = p;
continue;
}
diff --git a/src/nxt_runtime.h b/src/nxt_runtime.h
index d774aad3..f6d6aa53 100644
--- a/src/nxt_runtime.h
+++ b/src/nxt_runtime.h
@@ -58,6 +58,7 @@ struct nxt_runtime_s {
const char *pid;
const char *log;
const char *modules;
+ const char *control;
nxt_queue_t engines; /* of nxt_event_engine_t */