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".
This commit is contained in:
parent
897b860e83
commit
d3a6d7805f
4 changed files with 28 additions and 15 deletions
17
auto/options
17
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
|
||||
|
|
2
configure
vendored
2
configure
vendored
|
@ -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
|
||||
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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 */
|
||||
|
||||
|
|
Loading…
Reference in a new issue