diff options
author | Igor Sysoev <igor@sysoev.ru> | 2017-08-26 13:37:44 +0300 |
---|---|---|
committer | Igor Sysoev <igor@sysoev.ru> | 2017-08-26 13:37:44 +0300 |
commit | d3a6d7805f9f869f3a786080a9e0586b4844034f (patch) | |
tree | 5eb2c583830e70f4acb8f45a5059676f4784d38a | |
parent | 897b860e832c9eba67ba7d01d0775f64ade132f6 (diff) | |
download | unit-d3a6d7805f9f869f3a786080a9e0586b4844034f.tar.gz unit-d3a6d7805f9f869f3a786080a9e0586b4844034f.tar.bz2 |
Added configure options --prefix=PATH and --log=FILE.
A prefix is prepended to all relative names at configure stage.
There is no prefix by default.
A log file name can be relative.
The default log file name is "nginext.log".
-rw-r--r-- | auto/options | 17 | ||||
-rwxr-xr-x | configure | 2 | ||||
-rw-r--r-- | src/nxt_runtime.c | 22 | ||||
-rw-r--r-- | src/nxt_runtime.h | 2 |
4 files changed, 28 insertions, 15 deletions
diff --git a/auto/options b/auto/options index 57d8038f..7bd4606a 100644 --- a/auto/options +++ b/auto/options @@ -12,6 +12,9 @@ NXT_CFLAGS= NXT_CC_OPT= NXT_LD_OPT= +NXT_PREFIX= +NXT_LOG="nginext.log" + NXT_DEBUG=NO NXT_INET6=YES @@ -54,6 +57,9 @@ do --build-dir=*) NXT_BUILD_DIR="$value" ;; + --prefix=*) NXT_PREFIX="$value" ;; + --log=*) NXT_LOG="$value" ;; + --debug) NXT_DEBUG=YES ;; --no-ipv6) NXT_INET6=NO ;; @@ -94,3 +100,14 @@ do NXT_CONFIGURE_OPTIONS="$NXT_CONFIGURE_OPTIONS $nxt_opt" done + + +case "$NXT_PREFIX" in + ""|*/) ;; + *) NXT_PREFIX="$NXT_PREFIX/" ;; +esac + +case "$NXT_LOG" in + /*) ;; + *) NXT_LOG="$NXT_PREFIX$NXT_LOG" ;; +esac @@ -63,6 +63,8 @@ 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_LOG "$NXT_LOG" + END diff --git a/src/nxt_runtime.c b/src/nxt_runtime.c index d6b7c650..a60498d7 100644 --- a/src/nxt_runtime.c +++ b/src/nxt_runtime.c @@ -710,7 +710,7 @@ nxt_runtime_conf_init(nxt_task_t *task, nxt_runtime_t *rt) rt->user_cred.user = "nobody"; rt->group = NULL; rt->pid = "nginext.pid"; - rt->error_log = "error.log"; + rt->log = NXT_LOG; if (nxt_runtime_conf_read_cmd(task, rt) != NXT_OK) { return NXT_ERROR; @@ -743,10 +743,7 @@ nxt_runtime_conf_init(nxt_task_t *task, nxt_runtime_t *rt) rt->pid_file = file_name.start; - prefix = nxt_file_name_is_absolute(rt->error_log) ? NULL : rt->prefix; - - ret = nxt_file_name_create(rt->mem_pool, &file_name, "%V%s%Z", - prefix, rt->error_log); + ret = nxt_file_name_create(rt->mem_pool, &file_name, "%s%Z", rt->log); if (nxt_slow_path(ret != NXT_OK)) { return NXT_ERROR; } @@ -771,6 +768,8 @@ 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_log[] = "option \"--log\" requires filename\n"; + argv = &nxt_process_argv[1]; while (*argv != NULL) { @@ -858,14 +857,13 @@ nxt_runtime_conf_read_cmd(nxt_task_t *task, nxt_runtime_t *rt) if (nxt_strcmp(p, "--log") == 0) { if (*argv == NULL) { - nxt_log(task, NXT_LOG_CRIT, - "no argument for option \"--log\""); + write(STDERR_FILENO, no_log, sizeof(no_log) - 1); return NXT_ERROR; } p = *argv++; - rt->error_log = p; + rt->log = p; continue; } @@ -1239,7 +1237,7 @@ nxt_runtime_log_files_init(nxt_runtime_t *rt) if (nxt_fast_path(log_files != NULL)) { rt->log_files = log_files; - /* Preallocate the main error_log. This allocation cannot fail. */ + /* Preallocate the main log. This allocation cannot fail. */ file = nxt_list_zero_add(log_files); file->fd = NXT_FILE_INVALID; @@ -1256,14 +1254,10 @@ nxt_file_t * nxt_runtime_log_file_add(nxt_runtime_t *rt, nxt_str_t *name) { nxt_int_t ret; - nxt_str_t *prefix; nxt_file_t *file; nxt_file_name_str_t file_name; - prefix = nxt_file_name_is_absolute(name->start) ? NULL : rt->prefix; - - ret = nxt_file_name_create(rt->mem_pool, &file_name, "%V%V%Z", - prefix, name); + ret = nxt_file_name_create(rt->mem_pool, &file_name, "V%Z", name); if (nxt_slow_path(ret != NXT_OK)) { return NULL; diff --git a/src/nxt_runtime.h b/src/nxt_runtime.h index 4fa0f4f6..df8e162a 100644 --- a/src/nxt_runtime.h +++ b/src/nxt_runtime.h @@ -59,7 +59,7 @@ struct nxt_runtime_s { nxt_user_cred_t user_cred; const char *group; const char *pid; - const char *error_log; + const char *log; nxt_queue_t engines; /* of nxt_event_engine_t */ |