Mercurial > hg > nginx
comparison src/core/nginx.c @ 6187:1b7e246e6b38
Core: store and dump processed configuration.
If the -T option is passed, additionally to configuration test, configuration
files are output to stdout.
In the debug mode, configuration files are kept in memory and can be accessed
using a debugger.
author | Vladimir Homutov <vl@nginx.com> |
---|---|
date | Thu, 14 May 2015 18:54:27 +0300 |
parents | 967594ba7571 |
children | 5eb4d7541107 |
comparison
equal
deleted
inserted
replaced
6186:db138b3b645e | 6187:1b7e246e6b38 |
---|---|
174 | 174 |
175 | 175 |
176 int ngx_cdecl | 176 int ngx_cdecl |
177 main(int argc, char *const *argv) | 177 main(int argc, char *const *argv) |
178 { | 178 { |
179 ngx_int_t i; | 179 ngx_buf_t *b; |
180 ngx_log_t *log; | 180 ngx_log_t *log; |
181 ngx_uint_t i; | |
181 ngx_cycle_t *cycle, init_cycle; | 182 ngx_cycle_t *cycle, init_cycle; |
183 ngx_conf_dump_t *cd; | |
182 ngx_core_conf_t *ccf; | 184 ngx_core_conf_t *ccf; |
183 | 185 |
184 ngx_debug_init(); | 186 ngx_debug_init(); |
185 | 187 |
186 if (ngx_strerror_init() != NGX_OK) { | 188 if (ngx_strerror_init() != NGX_OK) { |
194 if (ngx_show_version) { | 196 if (ngx_show_version) { |
195 ngx_write_stderr("nginx version: " NGINX_VER_BUILD NGX_LINEFEED); | 197 ngx_write_stderr("nginx version: " NGINX_VER_BUILD NGX_LINEFEED); |
196 | 198 |
197 if (ngx_show_help) { | 199 if (ngx_show_help) { |
198 ngx_write_stderr( | 200 ngx_write_stderr( |
199 "Usage: nginx [-?hvVtq] [-s signal] [-c filename] " | 201 "Usage: nginx [-?hvVtTq] [-s signal] [-c filename] " |
200 "[-p prefix] [-g directives]" NGX_LINEFEED | 202 "[-p prefix] [-g directives]" NGX_LINEFEED |
201 NGX_LINEFEED | 203 NGX_LINEFEED |
202 "Options:" NGX_LINEFEED | 204 "Options:" NGX_LINEFEED |
203 " -?,-h : this help" NGX_LINEFEED | 205 " -?,-h : this help" NGX_LINEFEED |
204 " -v : show version and exit" NGX_LINEFEED | 206 " -v : show version and exit" NGX_LINEFEED |
205 " -V : show version and configure options then exit" | 207 " -V : show version and configure options then exit" |
206 NGX_LINEFEED | 208 NGX_LINEFEED |
207 " -t : test configuration and exit" NGX_LINEFEED | 209 " -t : test configuration and exit" NGX_LINEFEED |
210 " -T : test configuration, dump it and exit" | |
211 NGX_LINEFEED | |
208 " -q : suppress non-error messages " | 212 " -q : suppress non-error messages " |
209 "during configuration testing" NGX_LINEFEED | 213 "during configuration testing" NGX_LINEFEED |
210 " -s signal : send signal to a master process: " | 214 " -s signal : send signal to a master process: " |
211 "stop, quit, reopen, reload" NGX_LINEFEED | 215 "stop, quit, reopen, reload" NGX_LINEFEED |
212 #ifdef NGX_PREFIX | 216 #ifdef NGX_PREFIX |
331 if (!ngx_quiet_mode) { | 335 if (!ngx_quiet_mode) { |
332 ngx_log_stderr(0, "configuration file %s test is successful", | 336 ngx_log_stderr(0, "configuration file %s test is successful", |
333 cycle->conf_file.data); | 337 cycle->conf_file.data); |
334 } | 338 } |
335 | 339 |
340 if (ngx_dump_config) { | |
341 cd = cycle->config_dump.elts; | |
342 | |
343 for (i = 0; i < cycle->config_dump.nelts; i++) { | |
344 | |
345 ngx_write_stdout("# configuration file "); | |
346 (void) ngx_write_fd(ngx_stdout, cd[i].name.data, | |
347 cd[i].name.len); | |
348 ngx_write_stdout(":" NGX_LINEFEED); | |
349 | |
350 b = cd[i].buffer; | |
351 | |
352 (void) ngx_write_fd(ngx_stdout, b->pos, b->last - b->pos); | |
353 ngx_write_stdout(NGX_LINEFEED); | |
354 } | |
355 } | |
356 | |
336 return 0; | 357 return 0; |
337 } | 358 } |
338 | 359 |
339 if (ngx_signal) { | 360 if (ngx_signal) { |
340 return ngx_signal_process(cycle, ngx_signal); | 361 return ngx_signal_process(cycle, ngx_signal); |
687 | 708 |
688 case 't': | 709 case 't': |
689 ngx_test_config = 1; | 710 ngx_test_config = 1; |
690 break; | 711 break; |
691 | 712 |
713 case 'T': | |
714 ngx_test_config = 1; | |
715 ngx_dump_config = 1; | |
716 break; | |
717 | |
692 case 'q': | 718 case 'q': |
693 ngx_quiet_mode = 1; | 719 ngx_quiet_mode = 1; |
694 break; | 720 break; |
695 | 721 |
696 case 'p': | 722 case 'p': |