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
commite64494ba2cba9322f9594f26bcc69cb3a2441105 (patch)
tree4f0907e6f1000755a3d2f87c86932b18f1293401
parentd3a6d7805f9f869f3a786080a9e0586b4844034f (diff)
downloadunit-e64494ba2cba9322f9594f26bcc69cb3a2441105.tar.gz
unit-e64494ba2cba9322f9594f26bcc69cb3a2441105.tar.bz2
Added configure option --pid=FILE.
A pid file name can be relative. The default pid file name is "nginext.pid".
-rw-r--r--auto/options7
-rwxr-xr-xconfigure1
-rw-r--r--src/nxt_runtime.c19
-rw-r--r--src/nxt_runtime.h3
4 files changed, 12 insertions, 18 deletions
diff --git a/auto/options b/auto/options
index 7bd4606a..b7fcc179 100644
--- a/auto/options
+++ b/auto/options
@@ -13,6 +13,7 @@ NXT_CC_OPT=
NXT_LD_OPT=
NXT_PREFIX=
+NXT_PID="nginext.pid"
NXT_LOG="nginext.log"
NXT_DEBUG=NO
@@ -58,6 +59,7 @@ do
--build-dir=*) NXT_BUILD_DIR="$value" ;;
--prefix=*) NXT_PREFIX="$value" ;;
+ --pid=*) NXT_PID="$value" ;;
--log=*) NXT_LOG="$value" ;;
--debug) NXT_DEBUG=YES ;;
@@ -107,6 +109,11 @@ case "$NXT_PREFIX" in
*) NXT_PREFIX="$NXT_PREFIX/" ;;
esac
+case "$NXT_PID" in
+ /*) ;;
+ *) NXT_PID="$NXT_PREFIX$NXT_PID" ;;
+esac
+
case "$NXT_LOG" in
/*) ;;
*) NXT_LOG="$NXT_PREFIX$NXT_LOG" ;;
diff --git a/configure b/configure
index 63ecce82..a53ff106 100755
--- a/configure
+++ b/configure
@@ -63,6 +63,7 @@ cat << END >> $NXT_AUTO_CONFIG_H
#define NXT_SYSTEM_VERSION "$NXT_SYSTEM $NXT_SYSTEM_VERSION $NXT_SYSTEM_PLATFORM"
#define NXT_COMPILER_VERSION "$NXT_CC_VERSION"
+#define NXT_PID "$NXT_PID"
#define NXT_LOG "$NXT_LOG"
END
diff --git a/src/nxt_runtime.c b/src/nxt_runtime.c
index a60498d7..59b209aa 100644
--- a/src/nxt_runtime.c
+++ b/src/nxt_runtime.c
@@ -78,13 +78,6 @@ nxt_runtime_create(nxt_task_t *task)
nxt_thread_mutex_create(&rt->processes_mutex);
- rt->prefix = nxt_current_directory(mp);
- if (nxt_slow_path(rt->prefix == NULL)) {
- goto fail;
- }
-
- rt->conf_prefix = rt->prefix;
-
rt->services = nxt_services_init(mp);
if (nxt_slow_path(rt->services == NULL)) {
goto fail;
@@ -698,7 +691,6 @@ static nxt_int_t
nxt_runtime_conf_init(nxt_task_t *task, nxt_runtime_t *rt)
{
nxt_int_t ret;
- nxt_str_t *prefix;
nxt_file_t *file;
nxt_file_name_str_t file_name;
const nxt_event_interface_t *interface;
@@ -709,7 +701,7 @@ nxt_runtime_conf_init(nxt_task_t *task, nxt_runtime_t *rt)
rt->auxiliary_threads = 2;
rt->user_cred.user = "nobody";
rt->group = NULL;
- rt->pid = "nginext.pid";
+ rt->pid = NXT_PID;
rt->log = NXT_LOG;
if (nxt_runtime_conf_read_cmd(task, rt) != NXT_OK) {
@@ -733,10 +725,7 @@ nxt_runtime_conf_init(nxt_task_t *task, nxt_runtime_t *rt)
rt->engine = interface->name;
- prefix = nxt_file_name_is_absolute(rt->pid) ? NULL : rt->prefix;
-
- ret = nxt_file_name_create(rt->mem_pool, &file_name, "%V%s%Z",
- prefix, rt->pid);
+ ret = nxt_file_name_create(rt->mem_pool, &file_name, "s%Z", rt->pid);
if (nxt_slow_path(ret != NXT_OK)) {
return NXT_ERROR;
}
@@ -768,6 +757,7 @@ nxt_runtime_conf_read_cmd(nxt_task_t *task, nxt_runtime_t *rt)
"nginext version: " NXT_VERSION "\n"
"configured as ./configure" NXT_CONFIGURE_OPTIONS "\n";
+ static const char no_pid[] = "option \"--pid\" requires filename\n";
static const char no_log[] = "option \"--log\" requires filename\n";
argv = &nxt_process_argv[1];
@@ -843,8 +833,7 @@ nxt_runtime_conf_read_cmd(nxt_task_t *task, nxt_runtime_t *rt)
if (nxt_strcmp(p, "--pid") == 0) {
if (*argv == NULL) {
- nxt_log(task, NXT_LOG_CRIT,
- "no argument for option \"--pid\"");
+ write(STDERR_FILENO, no_pid, sizeof(no_pid) - 1);
return NXT_ERROR;
}
diff --git a/src/nxt_runtime.h b/src/nxt_runtime.h
index df8e162a..8741f08c 100644
--- a/src/nxt_runtime.h
+++ b/src/nxt_runtime.h
@@ -24,9 +24,6 @@ struct nxt_runtime_s {
nxt_runtime_cont_t start;
- nxt_str_t *conf_prefix;
- nxt_str_t *prefix;
-
nxt_str_t hostname;
nxt_file_name_t *pid_file;