Mercurial > hg > nginx
comparison src/core/nginx.c @ 2743:d8316f307b6a
issue start up errors and warning on both stderr and error_log
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Thu, 23 Apr 2009 11:13:12 +0000 |
parents | ae81441e23f4 |
children | 1983932b8075 |
comparison
equal
deleted
inserted
replaced
2742:e138f820b5dc | 2743:d8316f307b6a |
---|---|
205 if (ngx_get_options(argc, argv) != NGX_OK) { | 205 if (ngx_get_options(argc, argv) != NGX_OK) { |
206 return 1; | 206 return 1; |
207 } | 207 } |
208 | 208 |
209 if (ngx_show_version) { | 209 if (ngx_show_version) { |
210 ngx_log_stderr("nginx version: " NGINX_VER); | 210 ngx_log_stderr(0, "nginx version: " NGINX_VER); |
211 | 211 |
212 if (ngx_show_help) { | 212 if (ngx_show_help) { |
213 ngx_log_stderr( | 213 ngx_log_stderr(0, |
214 "Usage: nginx [-?hvVt] [-s signal] [-c filename] " | 214 "Usage: nginx [-?hvVt] [-s signal] [-c filename] " |
215 "[-g directives]" CRLF CRLF | 215 "[-g directives]" CRLF CRLF |
216 "Options:" CRLF | 216 "Options:" CRLF |
217 " -?,-h : this help" CRLF | 217 " -?,-h : this help" CRLF |
218 " -v : show version and exit" CRLF | 218 " -v : show version and exit" CRLF |
228 ); | 228 ); |
229 } | 229 } |
230 | 230 |
231 if (ngx_show_configure) { | 231 if (ngx_show_configure) { |
232 #ifdef NGX_COMPILER | 232 #ifdef NGX_COMPILER |
233 ngx_log_stderr("built by " NGX_COMPILER); | 233 ngx_log_stderr(0, "built by " NGX_COMPILER); |
234 #endif | 234 #endif |
235 ngx_log_stderr("configure arguments: " NGX_CONFIGURE); | 235 ngx_log_stderr(0, "configure arguments: " NGX_CONFIGURE); |
236 } | 236 } |
237 | 237 |
238 if (!ngx_test_config) { | 238 if (!ngx_test_config) { |
239 return 0; | 239 return 0; |
240 } | 240 } |
306 } | 306 } |
307 | 307 |
308 cycle = ngx_init_cycle(&init_cycle); | 308 cycle = ngx_init_cycle(&init_cycle); |
309 if (cycle == NULL) { | 309 if (cycle == NULL) { |
310 if (ngx_test_config) { | 310 if (ngx_test_config) { |
311 ngx_log_stderr("the configuration file %s test failed", | 311 ngx_log_stderr(0, "configuration file %s test failed", |
312 init_cycle.conf_file.data); | 312 init_cycle.conf_file.data); |
313 } | 313 } |
314 | 314 |
315 return 1; | 315 return 1; |
316 } | 316 } |
317 | 317 |
318 if (ngx_test_config) { | 318 if (ngx_test_config) { |
319 ngx_log_stderr("the configuration file %s was tested successfully", | 319 ngx_log_stderr(0, "configuration file %s test is successful", |
320 cycle->conf_file.data); | 320 cycle->conf_file.data); |
321 return 0; | 321 return 0; |
322 } | 322 } |
323 | 323 |
324 ngx_os_status(cycle->log); | 324 ngx_os_status(cycle->log); |
352 #endif | 352 #endif |
353 | 353 |
354 if (ngx_create_pidfile(&ccf->pid, cycle->log) != NGX_OK) { | 354 if (ngx_create_pidfile(&ccf->pid, cycle->log) != NGX_OK) { |
355 return 1; | 355 return 1; |
356 } | 356 } |
357 | |
358 if (cycle->log->file->fd != ngx_stderr) { | |
359 | |
360 if (ngx_set_stderr(cycle->log->file->fd) == NGX_FILE_ERROR) { | |
361 ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno, | |
362 ngx_set_stderr_n " failed"); | |
363 return 1; | |
364 } | |
365 } | |
366 | |
367 ngx_use_stderr = 0; | |
357 | 368 |
358 if (ngx_process == NGX_PROCESS_SINGLE) { | 369 if (ngx_process == NGX_PROCESS_SINGLE) { |
359 ngx_single_process_cycle(cycle); | 370 ngx_single_process_cycle(cycle); |
360 | 371 |
361 } else { | 372 } else { |
620 for (i = 1; i < argc; i++) { | 631 for (i = 1; i < argc; i++) { |
621 | 632 |
622 p = (u_char *) argv[i]; | 633 p = (u_char *) argv[i]; |
623 | 634 |
624 if (*p++ != '-') { | 635 if (*p++ != '-') { |
625 ngx_log_stderr("invalid option: \"%s\"", argv[i]); | 636 ngx_log_stderr(0, "invalid option: \"%s\"", argv[i]); |
626 return NGX_ERROR; | 637 return NGX_ERROR; |
627 } | 638 } |
628 | 639 |
629 while (*p) { | 640 while (*p) { |
630 | 641 |
658 if (argv[++i]) { | 669 if (argv[++i]) { |
659 ngx_conf_file = (u_char *) argv[i]; | 670 ngx_conf_file = (u_char *) argv[i]; |
660 goto next; | 671 goto next; |
661 } | 672 } |
662 | 673 |
663 ngx_log_stderr("the option \"-c\" requires file name"); | 674 ngx_log_stderr(0, "option \"-c\" requires file name"); |
664 return NGX_ERROR; | 675 return NGX_ERROR; |
665 | 676 |
666 case 'g': | 677 case 'g': |
667 if (*p) { | 678 if (*p) { |
668 ngx_conf_params = p; | 679 ngx_conf_params = p; |
672 if (argv[++i]) { | 683 if (argv[++i]) { |
673 ngx_conf_params = (u_char *) argv[i]; | 684 ngx_conf_params = (u_char *) argv[i]; |
674 goto next; | 685 goto next; |
675 } | 686 } |
676 | 687 |
677 ngx_log_stderr("the option \"-g\" requires parameter"); | 688 ngx_log_stderr(0, "option \"-g\" requires parameter"); |
678 return NGX_ERROR; | 689 return NGX_ERROR; |
679 | 690 |
680 case 's': | 691 case 's': |
681 if (*p) { | 692 if (*p) { |
682 ngx_signal = (char *) p; | 693 ngx_signal = (char *) p; |
683 | 694 |
684 } else if (argv[++i]) { | 695 } else if (argv[++i]) { |
685 ngx_signal = argv[i]; | 696 ngx_signal = argv[i]; |
686 | 697 |
687 } else { | 698 } else { |
688 ngx_log_stderr("the option \"-s\" requires parameter"); | 699 ngx_log_stderr(0, "option \"-s\" requires parameter"); |
689 return NGX_ERROR; | 700 return NGX_ERROR; |
690 } | 701 } |
691 | 702 |
692 if (ngx_strcmp(ngx_signal, "stop") == 0 | 703 if (ngx_strcmp(ngx_signal, "stop") == 0 |
693 || ngx_strcmp(ngx_signal, "quit") == 0 | 704 || ngx_strcmp(ngx_signal, "quit") == 0 |
696 { | 707 { |
697 ngx_process = NGX_PROCESS_SIGNALLER; | 708 ngx_process = NGX_PROCESS_SIGNALLER; |
698 goto next; | 709 goto next; |
699 } | 710 } |
700 | 711 |
701 ngx_log_stderr("invalid option: \"-s %s\"", ngx_signal); | 712 ngx_log_stderr(0, "invalid option: \"-s %s\"", ngx_signal); |
702 return NGX_ERROR; | 713 return NGX_ERROR; |
703 | 714 |
704 default: | 715 default: |
705 ngx_log_stderr("invalid option: \"%c\"", *(p - 1)); | 716 ngx_log_stderr(0, "invalid option: \"%c\"", *(p - 1)); |
706 return NGX_ERROR; | 717 return NGX_ERROR; |
707 } | 718 } |
708 } | 719 } |
709 | 720 |
710 next: | 721 next: |