mirror of
https://github.com/nginx/nginx.git
synced 2025-07-21 11:46:20 +08:00
Fix formatting
This commit is contained in:
parent
0cd3035d73
commit
2736632837
@ -394,9 +394,9 @@ static ngx_int_t
|
||||
ngx_install_windows_service()
|
||||
{
|
||||
wchar_t *install_commandline = NULL;
|
||||
wchar_t *i_opt_ptr = NULL;
|
||||
SC_HANDLE ScManagerHandle = NULL;
|
||||
SC_HANDLE NginxServiceHandle = NULL;
|
||||
wchar_t *i_opt_ptr = NULL;
|
||||
SC_HANDLE ScManagerHandle = NULL;
|
||||
SC_HANDLE NginxServiceHandle = NULL;
|
||||
|
||||
// Replace install commandline by service run commandline by
|
||||
// replacing the -i (install) option to a -w (windows service mode)
|
||||
@ -405,36 +405,36 @@ ngx_install_windows_service()
|
||||
i_opt_ptr[2] = 'w';
|
||||
printf("Installing NGINX service with commandline: %ls\n", install_commandline);
|
||||
|
||||
ScManagerHandle = OpenSCManagerW(NULL, NULL, SC_MANAGER_CONNECT | SC_MANAGER_CREATE_SERVICE);
|
||||
if (ScManagerHandle == NULL) {
|
||||
ngx_log_stderr(0, "OpenSCManagerW failed: errno == %d", ngx_errno);
|
||||
}
|
||||
ScManagerHandle = OpenSCManagerW(NULL, NULL, SC_MANAGER_CONNECT | SC_MANAGER_CREATE_SERVICE);
|
||||
if (ScManagerHandle == NULL) {
|
||||
ngx_log_stderr(0, "OpenSCManagerW failed: errno == %d", ngx_errno);
|
||||
}
|
||||
|
||||
//"nginx" as service name is hardcoded is ngx_service : use a define ?
|
||||
NginxServiceHandle = CreateServiceW(ScManagerHandle,
|
||||
L"nginx",
|
||||
L"Nginx server service",
|
||||
SERVICE_ALL_ACCESS,
|
||||
SERVICE_WIN32_OWN_PROCESS,
|
||||
SERVICE_DEMAND_START, // Auto-start ? let user change it manually in windows interface ?
|
||||
SERVICE_ERROR_NORMAL,
|
||||
install_commandline,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL, //L"NT AUTHORITY\\NetworkService", ?
|
||||
NULL);
|
||||
//"nginx" as service name is hardcoded is ngx_service : use a define ?
|
||||
NginxServiceHandle = CreateServiceW(ScManagerHandle,
|
||||
L"nginx",
|
||||
L"Nginx server service",
|
||||
SERVICE_ALL_ACCESS,
|
||||
SERVICE_WIN32_OWN_PROCESS,
|
||||
SERVICE_DEMAND_START, // Auto-start ? let user change it manually in windows interface ?
|
||||
SERVICE_ERROR_NORMAL,
|
||||
install_commandline,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL, //L"NT AUTHORITY\\NetworkService", ?
|
||||
NULL);
|
||||
|
||||
if (NginxServiceHandle == NULL) {
|
||||
ngx_log_stderr(0, "CreateServiceW failed: errno == %d", ngx_errno);
|
||||
CloseServiceHandle(ScManagerHandle);
|
||||
} else {
|
||||
printf("Service created !\n");
|
||||
}
|
||||
if (NginxServiceHandle == NULL) {
|
||||
ngx_log_stderr(0, "CreateServiceW failed: errno == %d", ngx_errno);
|
||||
CloseServiceHandle(ScManagerHandle);
|
||||
} else {
|
||||
printf("Service created !\n");
|
||||
}
|
||||
|
||||
CloseServiceHandle(NginxServiceHandle);
|
||||
CloseServiceHandle(ScManagerHandle);
|
||||
return 0;
|
||||
CloseServiceHandle(NginxServiceHandle);
|
||||
CloseServiceHandle(ScManagerHandle);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -980,18 +980,18 @@ ngx_get_options(int argc, char *const *argv)
|
||||
ngx_log_stderr(0, "invalid option: \"-s %s\"", ngx_signal);
|
||||
return NGX_ERROR;
|
||||
|
||||
#ifdef NGX_WIN32
|
||||
case 'i':
|
||||
// TODO: remove this option if not a Windows build ?
|
||||
ngx_install_windows_service();
|
||||
exit(0); // Do something else ?
|
||||
#ifdef NGX_WIN32
|
||||
case 'i':
|
||||
// TODO: remove this option if not a Windows build ?
|
||||
ngx_install_windows_service();
|
||||
exit(0); // Do something else ?
|
||||
|
||||
case 'w':
|
||||
// Run as windows service
|
||||
ngx_service = 1; // Error if other options (like -s) is provided ?
|
||||
goto next;
|
||||
case 'w':
|
||||
// Run as windows service
|
||||
ngx_service = 1; // Error if other options (like -s) is provided ?
|
||||
goto next;
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
default:
|
||||
ngx_log_stderr(0, "invalid option: \"%c\"", *(p - 1));
|
||||
@ -1150,11 +1150,11 @@ ngx_process_options(ngx_cycle_t *cycle)
|
||||
cycle->log->log_level = NGX_LOG_INFO;
|
||||
}
|
||||
|
||||
#if NGX_WIN32
|
||||
if (ngx_service) {
|
||||
cycle->service = 1;
|
||||
}
|
||||
#endif
|
||||
#if NGX_WIN32
|
||||
if (ngx_service) {
|
||||
cycle->service = 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
return NGX_OK;
|
||||
}
|
||||
|
@ -82,7 +82,7 @@ ngx_init_cycle(ngx_cycle_t *old_cycle)
|
||||
cycle->log = log;
|
||||
cycle->old_cycle = old_cycle;
|
||||
|
||||
cycle->service = old_cycle->service;
|
||||
cycle->service = old_cycle->service;
|
||||
|
||||
cycle->conf_prefix.len = old_cycle->conf_prefix.len;
|
||||
cycle->conf_prefix.data = ngx_pstrdup(pool, &old_cycle->conf_prefix);
|
||||
|
@ -83,7 +83,7 @@ struct ngx_cycle_s {
|
||||
ngx_str_t error_log;
|
||||
ngx_str_t lock_file;
|
||||
ngx_str_t hostname;
|
||||
ngx_uint_t service;
|
||||
ngx_uint_t service;
|
||||
};
|
||||
|
||||
|
||||
|
@ -121,13 +121,13 @@ ngx_master_process_cycle(ngx_cycle_t *cycle)
|
||||
|
||||
ngx_close_listening_sockets(cycle);
|
||||
|
||||
if (cycle->service){
|
||||
if (cycle->service){
|
||||
// Create only if this thread does not already exists ?
|
||||
if (ngx_create_thread(&servicetid, ngx_service_thread, NULL, cycle->log) != 0) {
|
||||
if (ngx_create_thread(&servicetid, ngx_service_thread, NULL, cycle->log) != 0) {
|
||||
ngx_log_error(NGX_LOG_ALERT, cycle->log, 0, "Creating ngx_service_thread failed");
|
||||
exit(2);
|
||||
}
|
||||
}
|
||||
exit(2);
|
||||
}
|
||||
}
|
||||
|
||||
if (ngx_start_worker_processes(cycle, NGX_PROCESS_RESPAWN) == 0) {
|
||||
exit(2);
|
||||
|
@ -101,7 +101,7 @@ service_main(DWORD dwNumServicesArgs, LPSTR *lpServiceArgVectors)
|
||||
|
||||
int report_service_stop_status(DWORD dwCurrentState)
|
||||
{
|
||||
SERVICE_STATUS status;
|
||||
SERVICE_STATUS status;
|
||||
|
||||
status.dwServiceType = SERVICE_WIN32_OWN_PROCESS;
|
||||
status.dwCurrentState = dwCurrentState;
|
||||
@ -128,24 +128,24 @@ service_handler(DWORD control, DWORD type, void *data, void *ctx)
|
||||
// case SERVICE_CONTROL_INTERROGATE:
|
||||
// status = NGX_IOCP_INTERROGATE;
|
||||
// break;
|
||||
//
|
||||
//
|
||||
case SERVICE_CONTROL_STOP:
|
||||
report_service_stop_status(SERVICE_STOP_PENDING);
|
||||
if (SetEvent(ngx_stop_event) == 0) {
|
||||
report_service_stop_status(SERVICE_STOP_PENDING);
|
||||
if (SetEvent(ngx_stop_event) == 0) {
|
||||
ngx_log_error(NGX_LOG_EMERG, ngx_cycle->log, ngx_errno,
|
||||
"SetEvent(ngx_stop_event) failed");
|
||||
}
|
||||
report_service_stop_status(SERVICE_STOPPED);
|
||||
}
|
||||
report_service_stop_status(SERVICE_STOPPED);
|
||||
break;
|
||||
//
|
||||
//
|
||||
// case SERVICE_CONTROL_PARAMCHANGE:
|
||||
// status = NGX_IOCP_RECONFIGURE;
|
||||
// break;
|
||||
//
|
||||
//
|
||||
// case NGX_SERVICE_CONTROL_SHUTDOWN:
|
||||
// status = NGX_IOCP_REOPEN;
|
||||
// break;
|
||||
//
|
||||
//
|
||||
// case NGX_SERVICE_CONTROL_REOPEN:
|
||||
// status = NGX_IOCP_REOPEN;
|
||||
// break;
|
||||
@ -153,5 +153,5 @@ service_handler(DWORD control, DWORD type, void *data, void *ctx)
|
||||
default:
|
||||
return ERROR_CALL_NOT_IMPLEMENTED;
|
||||
}
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user