Mercurial > hg > nginx-mail
comparison src/core/nginx.c @ 665:0b460e61bdcd default tip
Merge with nginx 1.0.0.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Mon, 25 Apr 2011 04:22:17 +0400 |
parents | 428c6e58046a |
children |
comparison
equal
deleted
inserted
replaced
572:06419a2298a9 | 665:0b460e61bdcd |
---|---|
108 offsetof(ngx_core_conf_t, rlimit_nofile), | 108 offsetof(ngx_core_conf_t, rlimit_nofile), |
109 NULL }, | 109 NULL }, |
110 | 110 |
111 { ngx_string("worker_rlimit_core"), | 111 { ngx_string("worker_rlimit_core"), |
112 NGX_MAIN_CONF|NGX_DIRECT_CONF|NGX_CONF_TAKE1, | 112 NGX_MAIN_CONF|NGX_DIRECT_CONF|NGX_CONF_TAKE1, |
113 ngx_conf_set_size_slot, | 113 ngx_conf_set_off_slot, |
114 0, | 114 0, |
115 offsetof(ngx_core_conf_t, rlimit_core), | 115 offsetof(ngx_core_conf_t, rlimit_core), |
116 NULL }, | 116 NULL }, |
117 | 117 |
118 { ngx_string("worker_rlimit_sigpending"), | 118 { ngx_string("worker_rlimit_sigpending"), |
201 ngx_int_t i; | 201 ngx_int_t i; |
202 ngx_log_t *log; | 202 ngx_log_t *log; |
203 ngx_cycle_t *cycle, init_cycle; | 203 ngx_cycle_t *cycle, init_cycle; |
204 ngx_core_conf_t *ccf; | 204 ngx_core_conf_t *ccf; |
205 | 205 |
206 if (ngx_strerror_init() != NGX_OK) { | |
207 return 1; | |
208 } | |
209 | |
206 if (ngx_get_options(argc, argv) != NGX_OK) { | 210 if (ngx_get_options(argc, argv) != NGX_OK) { |
207 return 1; | 211 return 1; |
208 } | 212 } |
209 | 213 |
210 if (ngx_show_version) { | 214 if (ngx_show_version) { |
211 ngx_log_stderr(0, "nginx version: " NGINX_VER); | 215 ngx_log_stderr(0, "nginx version: " NGINX_VER); |
212 | 216 |
213 if (ngx_show_help) { | 217 if (ngx_show_help) { |
214 ngx_log_stderr(0, | 218 ngx_log_stderr(0, |
215 "Usage: nginx [-?hvVt] [-s signal] [-c filename] " | 219 "Usage: nginx [-?hvVtq] [-s signal] [-c filename] " |
216 "[-p prefix] [-g directives]" CRLF CRLF | 220 "[-p prefix] [-g directives]" CRLF CRLF |
217 "Options:" CRLF | 221 "Options:" CRLF |
218 " -?,-h : this help" CRLF | 222 " -?,-h : this help" CRLF |
219 " -v : show version and exit" CRLF | 223 " -v : show version and exit" CRLF |
220 " -V : show version and configure options then exit" | 224 " -V : show version and configure options then exit" |
221 CRLF | 225 CRLF |
222 " -t : test configuration and exit" CRLF | 226 " -t : test configuration and exit" CRLF |
227 " -q : suppress non-error messages " | |
228 "during configuration testing" CRLF | |
223 " -s signal : send signal to a master process: " | 229 " -s signal : send signal to a master process: " |
224 "stop, quit, reopen, reload" CRLF | 230 "stop, quit, reopen, reload" CRLF |
225 #ifdef NGX_PREFIX | 231 #ifdef NGX_PREFIX |
226 " -p prefix : set prefix path (default: " | 232 " -p prefix : set prefix path (default: " |
227 NGX_PREFIX ")" CRLF | 233 NGX_PREFIX ")" CRLF |
237 | 243 |
238 if (ngx_show_configure) { | 244 if (ngx_show_configure) { |
239 #ifdef NGX_COMPILER | 245 #ifdef NGX_COMPILER |
240 ngx_log_stderr(0, "built by " NGX_COMPILER); | 246 ngx_log_stderr(0, "built by " NGX_COMPILER); |
241 #endif | 247 #endif |
248 #if (NGX_SSL) | |
249 #ifdef SSL_CTRL_SET_TLSEXT_HOSTNAME | |
250 ngx_log_stderr(0, "TLS SNI support enabled"); | |
251 #else | |
252 ngx_log_stderr(0, "TLS SNI support disabled"); | |
253 #endif | |
254 #endif | |
242 ngx_log_stderr(0, "configure arguments:" NGX_CONFIGURE); | 255 ngx_log_stderr(0, "configure arguments:" NGX_CONFIGURE); |
243 } | 256 } |
244 | 257 |
245 if (!ngx_test_config) { | 258 if (!ngx_test_config) { |
246 return 0; | 259 return 0; |
323 | 336 |
324 return 1; | 337 return 1; |
325 } | 338 } |
326 | 339 |
327 if (ngx_test_config) { | 340 if (ngx_test_config) { |
328 ngx_log_stderr(0, "configuration file %s test is successful", | 341 if (!ngx_quiet_mode) { |
329 cycle->conf_file.data); | 342 ngx_log_stderr(0, "configuration file %s test is successful", |
343 cycle->conf_file.data); | |
344 } | |
345 | |
330 return 0; | 346 return 0; |
331 } | 347 } |
332 | 348 |
333 if (ngx_signal) { | 349 if (ngx_signal) { |
334 return ngx_signal_process(cycle, ngx_signal); | 350 return ngx_signal_process(cycle, ngx_signal); |
368 | 384 |
369 if (ngx_set_stderr(cycle->log->file->fd) == NGX_FILE_ERROR) { | 385 if (ngx_set_stderr(cycle->log->file->fd) == NGX_FILE_ERROR) { |
370 ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno, | 386 ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno, |
371 ngx_set_stderr_n " failed"); | 387 ngx_set_stderr_n " failed"); |
372 return 1; | 388 return 1; |
389 } | |
390 } | |
391 | |
392 if (log->file->fd != ngx_stderr) { | |
393 if (ngx_close_file(log->file->fd) == NGX_FILE_ERROR) { | |
394 ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno, | |
395 ngx_close_file_n " built-in log failed"); | |
373 } | 396 } |
374 } | 397 } |
375 | 398 |
376 ngx_use_stderr = 0; | 399 ngx_use_stderr = 0; |
377 | 400 |
669 | 692 |
670 case 't': | 693 case 't': |
671 ngx_test_config = 1; | 694 ngx_test_config = 1; |
672 break; | 695 break; |
673 | 696 |
697 case 'q': | |
698 ngx_quiet_mode = 1; | |
699 break; | |
700 | |
674 case 'p': | 701 case 'p': |
675 if (*p) { | 702 if (*p) { |
676 ngx_prefix = p; | 703 ngx_prefix = p; |
677 goto next; | 704 goto next; |
678 } | 705 } |
843 cycle->prefix.data = p; | 870 cycle->prefix.data = p; |
844 | 871 |
845 #else | 872 #else |
846 | 873 |
847 #ifdef NGX_CONF_PREFIX | 874 #ifdef NGX_CONF_PREFIX |
848 cycle->conf_prefix.len = sizeof(NGX_CONF_PREFIX) - 1; | 875 ngx_str_set(&cycle->conf_prefix, NGX_CONF_PREFIX); |
849 cycle->conf_prefix.data = (u_char *) NGX_CONF_PREFIX; | |
850 #else | 876 #else |
851 cycle->conf_prefix.len = sizeof(NGX_PREFIX) - 1; | 877 ngx_str_set(&cycle->conf_prefix, NGX_PREFIX); |
852 cycle->conf_prefix.data = (u_char *) NGX_PREFIX; | 878 #endif |
853 #endif | 879 ngx_str_set(&cycle->prefix, NGX_PREFIX); |
854 cycle->prefix.len = sizeof(NGX_PREFIX) - 1; | |
855 cycle->prefix.data = (u_char *) NGX_PREFIX; | |
856 | 880 |
857 #endif | 881 #endif |
858 } | 882 } |
859 | 883 |
860 if (ngx_conf_file) { | 884 if (ngx_conf_file) { |
861 cycle->conf_file.len = ngx_strlen(ngx_conf_file); | 885 cycle->conf_file.len = ngx_strlen(ngx_conf_file); |
862 cycle->conf_file.data = ngx_conf_file; | 886 cycle->conf_file.data = ngx_conf_file; |
863 | 887 |
864 } else { | 888 } else { |
865 cycle->conf_file.len = sizeof(NGX_CONF_PATH) - 1; | 889 ngx_str_set(&cycle->conf_file, NGX_CONF_PATH); |
866 cycle->conf_file.data = (u_char *) NGX_CONF_PATH; | |
867 } | 890 } |
868 | 891 |
869 if (ngx_conf_full_name(cycle, &cycle->conf_file, 0) != NGX_OK) { | 892 if (ngx_conf_full_name(cycle, &cycle->conf_file, 0) != NGX_OK) { |
870 return NGX_ERROR; | 893 return NGX_ERROR; |
871 } | 894 } |
903 if (ccf == NULL) { | 926 if (ccf == NULL) { |
904 return NULL; | 927 return NULL; |
905 } | 928 } |
906 | 929 |
907 /* | 930 /* |
908 * set by pcalloc() | 931 * set by ngx_pcalloc() |
909 * | 932 * |
910 * ccf->pid = NULL; | 933 * ccf->pid = NULL; |
911 * ccf->oldpid = NULL; | 934 * ccf->oldpid = NULL; |
912 * ccf->priority = 0; | 935 * ccf->priority = 0; |
913 * ccf->cpu_affinity_n = 0; | 936 * ccf->cpu_affinity_n = 0; |
920 | 943 |
921 ccf->worker_processes = NGX_CONF_UNSET; | 944 ccf->worker_processes = NGX_CONF_UNSET; |
922 ccf->debug_points = NGX_CONF_UNSET; | 945 ccf->debug_points = NGX_CONF_UNSET; |
923 | 946 |
924 ccf->rlimit_nofile = NGX_CONF_UNSET; | 947 ccf->rlimit_nofile = NGX_CONF_UNSET; |
925 ccf->rlimit_core = NGX_CONF_UNSET_SIZE; | 948 ccf->rlimit_core = NGX_CONF_UNSET; |
926 ccf->rlimit_sigpending = NGX_CONF_UNSET; | 949 ccf->rlimit_sigpending = NGX_CONF_UNSET; |
927 | 950 |
928 ccf->user = (ngx_uid_t) NGX_CONF_UNSET_UINT; | 951 ccf->user = (ngx_uid_t) NGX_CONF_UNSET_UINT; |
929 ccf->group = (ngx_gid_t) NGX_CONF_UNSET_UINT; | 952 ccf->group = (ngx_gid_t) NGX_CONF_UNSET_UINT; |
930 | 953 |
977 | 1000 |
978 #endif | 1001 #endif |
979 | 1002 |
980 | 1003 |
981 if (ccf->pid.len == 0) { | 1004 if (ccf->pid.len == 0) { |
982 ccf->pid.len = sizeof(NGX_PID_PATH) - 1; | 1005 ngx_str_set(&ccf->pid, NGX_PID_PATH); |
983 ccf->pid.data = (u_char *) NGX_PID_PATH; | |
984 } | 1006 } |
985 | 1007 |
986 if (ngx_conf_full_name(cycle, &ccf->pid, 0) != NGX_OK) { | 1008 if (ngx_conf_full_name(cycle, &ccf->pid, 0) != NGX_OK) { |
987 return NGX_CONF_ERROR; | 1009 return NGX_CONF_ERROR; |
988 } | 1010 } |
1026 ccf->group = grp->gr_gid; | 1048 ccf->group = grp->gr_gid; |
1027 } | 1049 } |
1028 | 1050 |
1029 | 1051 |
1030 if (ccf->lock_file.len == 0) { | 1052 if (ccf->lock_file.len == 0) { |
1031 ccf->lock_file.len = sizeof(NGX_LOCK_PATH) - 1; | 1053 ngx_str_set(&ccf->lock_file, NGX_LOCK_PATH); |
1032 ccf->lock_file.data = (u_char *) NGX_LOCK_PATH; | |
1033 } | 1054 } |
1034 | 1055 |
1035 if (ngx_conf_full_name(cycle, &ccf->lock_file, 0) != NGX_OK) { | 1056 if (ngx_conf_full_name(cycle, &ccf->lock_file, 0) != NGX_OK) { |
1036 return NGX_CONF_ERROR; | 1057 return NGX_CONF_ERROR; |
1037 } | 1058 } |