Mercurial > hg > nginx
comparison src/core/ngx_cycle.c @ 9268:6a3ee145d0b5
Core: made it possible to disable PID files with "pid off".
While it is not generally recommended, this might be beneficial in some
configurations, such as with immutable images and direct control by
a service manager.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Mon, 13 May 2024 06:13:03 +0300 |
parents | f18db38a9826 |
children | 4eb02e5ddb48 |
comparison
equal
deleted
inserted
replaced
9267:9a5e2296c1be | 9268:6a3ee145d0b5 |
---|---|
1025 | 1025 |
1026 if (ngx_process > NGX_PROCESS_MASTER) { | 1026 if (ngx_process > NGX_PROCESS_MASTER) { |
1027 return NGX_OK; | 1027 return NGX_OK; |
1028 } | 1028 } |
1029 | 1029 |
1030 if (name->len == 0) { | |
1031 return NGX_OK; | |
1032 } | |
1033 | |
1030 ngx_memzero(&file, sizeof(ngx_file_t)); | 1034 ngx_memzero(&file, sizeof(ngx_file_t)); |
1031 | 1035 |
1032 file.name = *name; | 1036 file.name = *name; |
1033 file.log = log; | 1037 file.log = log; |
1034 | 1038 |
1067 { | 1071 { |
1068 u_char *name; | 1072 u_char *name; |
1069 ngx_core_conf_t *ccf; | 1073 ngx_core_conf_t *ccf; |
1070 | 1074 |
1071 ccf = (ngx_core_conf_t *) ngx_get_conf(cycle->conf_ctx, ngx_core_module); | 1075 ccf = (ngx_core_conf_t *) ngx_get_conf(cycle->conf_ctx, ngx_core_module); |
1076 | |
1077 if (ccf->pid.len == 0) { | |
1078 return; | |
1079 } | |
1072 | 1080 |
1073 name = ngx_new_binary ? ccf->oldpid.data : ccf->pid.data; | 1081 name = ngx_new_binary ? ccf->oldpid.data : ccf->pid.data; |
1074 | 1082 |
1075 if (ngx_delete_file(name) == NGX_FILE_ERROR) { | 1083 if (ngx_delete_file(name) == NGX_FILE_ERROR) { |
1076 ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno, | 1084 ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno, |
1089 u_char buf[NGX_INT64_LEN + 2]; | 1097 u_char buf[NGX_INT64_LEN + 2]; |
1090 | 1098 |
1091 ngx_log_error(NGX_LOG_NOTICE, cycle->log, 0, "signal process started"); | 1099 ngx_log_error(NGX_LOG_NOTICE, cycle->log, 0, "signal process started"); |
1092 | 1100 |
1093 ccf = (ngx_core_conf_t *) ngx_get_conf(cycle->conf_ctx, ngx_core_module); | 1101 ccf = (ngx_core_conf_t *) ngx_get_conf(cycle->conf_ctx, ngx_core_module); |
1102 | |
1103 if (ccf->pid.len == 0) { | |
1104 ngx_log_error(NGX_LOG_ERR, cycle->log, 0, | |
1105 "no PID file configured"); | |
1106 return 1; | |
1107 } | |
1094 | 1108 |
1095 ngx_memzero(&file, sizeof(ngx_file_t)); | 1109 ngx_memzero(&file, sizeof(ngx_file_t)); |
1096 | 1110 |
1097 file.name = ccf->pid; | 1111 file.name = ccf->pid; |
1098 file.log = cycle->log; | 1112 file.log = cycle->log; |