aboutsummaryrefslogtreecommitdiff
path: root/src/core/nginx.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/nginx.c')
-rw-r--r--src/core/nginx.c100
1 files changed, 61 insertions, 39 deletions
diff --git a/src/core/nginx.c b/src/core/nginx.c
index a542eca74..cfc2337f1 100644
--- a/src/core/nginx.c
+++ b/src/core/nginx.c
@@ -180,10 +180,14 @@ ngx_module_t ngx_core_module = {
};
-ngx_uint_t ngx_max_module;
+ngx_uint_t ngx_max_module;
+
+static ngx_uint_t ngx_show_version;
+static ngx_uint_t ngx_show_configure;
+#if (NGX_WIN32)
+static char *ngx_signal;
+#endif
-static ngx_uint_t ngx_show_version;
-static ngx_uint_t ngx_show_configure;
static char **ngx_os_environ;
@@ -303,22 +307,15 @@ main(int argc, char *const *argv)
ccf = (ngx_core_conf_t *) ngx_get_conf(cycle->conf_ctx, ngx_core_module);
- ngx_process = ccf->master ? NGX_PROCESS_MASTER : NGX_PROCESS_SINGLE;
+ if (ccf->master && ngx_process == NGX_PROCESS_SINGLE) {
+ ngx_process = NGX_PROCESS_MASTER;
+ }
#if (NGX_WIN32)
-#if 0
-
- TODO:
-
- if (ccf->run_as_service) {
- if (ngx_service(cycle->log) != NGX_OK) {
- return 1;
- }
-
- return 0;
+ if (ngx_signal) {
+ return ngx_signal_process(cycle, ngx_signal);
}
-#endif
#else
@@ -334,17 +331,17 @@ main(int argc, char *const *argv)
ngx_daemonized = 1;
}
+#endif
+
if (ngx_create_pidfile(&ccf->pid, cycle->log) != NGX_OK) {
return 1;
}
-#endif
-
- if (ngx_process == NGX_PROCESS_MASTER) {
- ngx_master_process_cycle(cycle);
+ if (ngx_process == NGX_PROCESS_SINGLE) {
+ ngx_single_process_cycle(cycle);
} else {
- ngx_single_process_cycle(cycle);
+ ngx_master_process_cycle(cycle);
}
return 0;
@@ -645,6 +642,29 @@ ngx_getopt(ngx_cycle_t *cycle, int argc, char *const *argv)
cycle->conf_param.len = ngx_strlen(cycle->conf_param.data);
break;
+#if (NGX_WIN32)
+ case 's':
+ if (argv[++i] == NULL) {
+ ngx_log_error(NGX_LOG_EMERG, cycle->log, 0,
+ "the option \"-s\" requires parameter");
+ return NGX_ERROR;
+ }
+
+ if (ngx_strcmp(argv[i], "stop") == 0
+ || ngx_strcmp(argv[i], "quit") == 0
+ || ngx_strcmp(argv[i], "reopen") == 0
+ || ngx_strcmp(argv[i], "reload") == 0)
+ {
+ ngx_process = NGX_PROCESS_SIGNALLER;
+ ngx_signal = argv[i];
+ break;
+ }
+
+ ngx_log_error(NGX_LOG_EMERG, cycle->log, 0,
+ "invalid option: \"-s %s\"", argv[i]);
+ return NGX_ERROR;
+#endif
+
default:
ngx_log_error(NGX_LOG_EMERG, cycle->log, 0,
"invalid option: \"%s\"", argv[i]);
@@ -786,6 +806,27 @@ ngx_core_module_init_conf(ngx_cycle_t *cycle, void *conf)
#endif
+
+ if (ccf->pid.len == 0) {
+ ccf->pid.len = sizeof(NGX_PID_PATH) - 1;
+ ccf->pid.data = (u_char *) NGX_PID_PATH;
+ }
+
+ if (ngx_conf_full_name(cycle, &ccf->pid, 0) != NGX_OK) {
+ return NGX_CONF_ERROR;
+ }
+
+ ccf->oldpid.len = ccf->pid.len + sizeof(NGX_OLDPID_EXT);
+
+ ccf->oldpid.data = ngx_pnalloc(cycle->pool, ccf->oldpid.len);
+ if (ccf->oldpid.data == NULL) {
+ return NGX_CONF_ERROR;
+ }
+
+ ngx_memcpy(ngx_cpymem(ccf->oldpid.data, ccf->pid.data, ccf->pid.len),
+ NGX_OLDPID_EXT, sizeof(NGX_OLDPID_EXT));
+
+
#if !(NGX_WIN32)
if (ccf->user == (uid_t) NGX_CONF_UNSET_UINT && geteuid() == 0) {
@@ -814,25 +855,6 @@ ngx_core_module_init_conf(ngx_cycle_t *cycle, void *conf)
ccf->group = grp->gr_gid;
}
- if (ccf->pid.len == 0) {
- ccf->pid.len = sizeof(NGX_PID_PATH) - 1;
- ccf->pid.data = (u_char *) NGX_PID_PATH;
- }
-
- if (ngx_conf_full_name(cycle, &ccf->pid, 0) != NGX_OK) {
- return NGX_CONF_ERROR;
- }
-
- ccf->oldpid.len = ccf->pid.len + sizeof(NGX_OLDPID_EXT);
-
- ccf->oldpid.data = ngx_pnalloc(cycle->pool, ccf->oldpid.len);
- if (ccf->oldpid.data == NULL) {
- return NGX_CONF_ERROR;
- }
-
- ngx_memcpy(ngx_cpymem(ccf->oldpid.data, ccf->pid.data, ccf->pid.len),
- NGX_OLDPID_EXT, sizeof(NGX_OLDPID_EXT));
-
if (ccf->lock_file.len == 0) {
ccf->lock_file.len = sizeof(NGX_LOCK_PATH) - 1;