summaryrefslogtreecommitdiffhomepage
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
commit7f5b57bfb9a61ce0ba3fbc74f1775ace2d8ec6ec (patch)
tree37f69782ab933eb36d305d8d3e6e90c42417a711
parent9aaa7d8c20e58ed380225cbbbd05248539d2f500 (diff)
downloadunit-7f5b57bfb9a61ce0ba3fbc74f1775ace2d8ec6ec.tar.gz
unit-7f5b57bfb9a61ce0ba3fbc74f1775ace2d8ec6ec.tar.bz2
Added configure and command line option --modules.
-rw-r--r--auto/options12
-rwxr-xr-xconfigure1
-rw-r--r--src/nxt_application.c5
-rw-r--r--src/nxt_runtime.c24
-rw-r--r--src/nxt_runtime.h1
5 files changed, 41 insertions, 2 deletions
diff --git a/auto/options b/auto/options
index bcf9e17a..b013a7ae 100644
--- a/auto/options
+++ b/auto/options
@@ -15,6 +15,7 @@ NXT_LD_OPT=
NXT_PREFIX=
NXT_PID="nginext.pid"
NXT_LOG="nginext.log"
+NXT_MODULES="modules"
NXT_USER="nobody"
NXT_GROUP=
@@ -64,6 +65,7 @@ do
--prefix=*) NXT_PREFIX="$value" ;;
--pid=*) NXT_PID="$value" ;;
--log=*) NXT_LOG="$value" ;;
+ --modules=*) NXT_MODULES="$value" ;;
--user=*) NXT_USER="$value" ;;
--group=*) NXT_GROUP="$value" ;;
@@ -124,3 +126,13 @@ case "$NXT_LOG" in
/*) ;;
*) NXT_LOG="$NXT_PREFIX$NXT_LOG" ;;
esac
+
+case "$NXT_MODULES" in
+ ""|*/) ;;
+ *) NXT_MODULES="$NXT_MODULES/" ;;
+esac
+
+case "$NXT_MODULES" in
+ /*) ;;
+ *) NXT_MODULES="$NXT_PREFIX$NXT_MODULES" ;;
+esac
diff --git a/configure b/configure
index b0741687..2380e518 100755
--- a/configure
+++ b/configure
@@ -65,6 +65,7 @@ cat << END >> $NXT_AUTO_CONFIG_H
#define NXT_PID "$NXT_PID"
#define NXT_LOG "$NXT_LOG"
+#define NXT_MODULES "$NXT_MODULES"
#define NXT_USER "$NXT_USER"
#define NXT_GROUP "$NXT_GROUP"
diff --git a/src/nxt_application.c b/src/nxt_application.c
index 4689f622..23182401 100644
--- a/src/nxt_application.c
+++ b/src/nxt_application.c
@@ -46,9 +46,10 @@ nxt_discovery_start(nxt_task_t *task, void *data)
nxt_debug(task, "DISCOVERY");
- b = nxt_discovery_modules(task, "build/nginext.*");
-
rt = task->thread->runtime;
+
+ b = nxt_discovery_modules(task, rt->modules);
+
main_port = rt->port_by_type[NXT_PROCESS_MASTER];
nxt_port_socket_write(task, main_port, NXT_PORT_MSG_MODULES, -1,
diff --git a/src/nxt_runtime.c b/src/nxt_runtime.c
index d6518fbe..f070bd94 100644
--- a/src/nxt_runtime.c
+++ b/src/nxt_runtime.c
@@ -703,6 +703,7 @@ 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;
if (nxt_runtime_conf_read_cmd(task, rt) != NXT_OK) {
return NXT_ERROR;
@@ -740,6 +741,14 @@ nxt_runtime_conf_init(nxt_task_t *task, nxt_runtime_t *rt)
file = nxt_list_first(rt->log_files);
file->name = file_name.start;
+ ret = nxt_file_name_create(rt->mem_pool, &file_name, "%snginext.*%Z",
+ rt->modules);
+ if (nxt_slow_path(ret != NXT_OK)) {
+ return NXT_ERROR;
+ }
+
+ rt->modules = (char *) file_name.start;
+
return NXT_OK;
}
@@ -761,6 +770,8 @@ nxt_runtime_conf_read_cmd(nxt_task_t *task, nxt_runtime_t *rt)
static const char no_group[] = "option \"--group\" requires group name\n";
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";
argv = &nxt_process_argv[1];
@@ -857,6 +868,19 @@ nxt_runtime_conf_read_cmd(nxt_task_t *task, nxt_runtime_t *rt)
continue;
}
+ if (nxt_strcmp(p, "--modules") == 0) {
+ if (*argv == NULL) {
+ write(STDERR_FILENO, no_modules, sizeof(no_modules) - 1);
+ return NXT_ERROR;
+ }
+
+ p = *argv++;
+
+ rt->modules = p;
+
+ continue;
+ }
+
if (nxt_strcmp(p, "--no-daemon") == 0) {
rt->daemon = 0;
continue;
diff --git a/src/nxt_runtime.h b/src/nxt_runtime.h
index 8741f08c..d774aad3 100644
--- a/src/nxt_runtime.h
+++ b/src/nxt_runtime.h
@@ -57,6 +57,7 @@ struct nxt_runtime_s {
const char *group;
const char *pid;
const char *log;
+ const char *modules;
nxt_queue_t engines; /* of nxt_event_engine_t */