Mercurial > hg > nginx
diff src/core/nginx.c @ 2725:d43d73277c5c
Win32 master/workers model
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Mon, 20 Apr 2009 06:08:47 +0000 |
parents | ffa8e2451457 |
children | 95a17423afdb |
line wrap: on
line diff
--- a/src/core/nginx.c Sun Apr 19 19:08:49 2009 +0000 +++ b/src/core/nginx.c Mon Apr 20 06:08:47 2009 +0000 @@ -180,10 +180,14 @@ }; -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; +static ngx_uint_t ngx_show_version; +static ngx_uint_t ngx_show_configure; +#if (NGX_WIN32) +static char *ngx_signal; +#endif + static char **ngx_os_environ; @@ -303,22 +307,15 @@ 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 @@ 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 @@ 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 @@ #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 @@ 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;