Added configure option --pid=FILE.

A pid file name can be relative.
The default pid file name is "nginext.pid".
This commit is contained in:
Igor Sysoev
2017-08-26 13:37:44 +03:00
parent d3a6d7805f
commit e64494ba2c
4 changed files with 12 additions and 18 deletions

View File

@@ -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" ;;

1
configure vendored
View File

@@ -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

View File

@@ -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;
}

View File

@@ -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;