Mercurial > hg > nginx-quic
comparison src/core/nginx.c @ 4890:173cd5458281
Core: the "auto" parameter of the "worker_processes" directive.
The parameter will set the number of worker processes to the
autodetected number of available CPU cores.
author | Andrey Belov <defan@nginx.com> |
---|---|
date | Tue, 23 Oct 2012 09:08:41 +0000 |
parents | 2220ce29b9d3 |
children | 4d7027deb1bb f1521859b8c2 |
comparison
equal
deleted
inserted
replaced
4889:a50ed82f19e4 | 4890:173cd5458281 |
---|---|
19 static char *ngx_set_user(ngx_conf_t *cf, ngx_command_t *cmd, void *conf); | 19 static char *ngx_set_user(ngx_conf_t *cf, ngx_command_t *cmd, void *conf); |
20 static char *ngx_set_env(ngx_conf_t *cf, ngx_command_t *cmd, void *conf); | 20 static char *ngx_set_env(ngx_conf_t *cf, ngx_command_t *cmd, void *conf); |
21 static char *ngx_set_priority(ngx_conf_t *cf, ngx_command_t *cmd, void *conf); | 21 static char *ngx_set_priority(ngx_conf_t *cf, ngx_command_t *cmd, void *conf); |
22 static char *ngx_set_cpu_affinity(ngx_conf_t *cf, ngx_command_t *cmd, | 22 static char *ngx_set_cpu_affinity(ngx_conf_t *cf, ngx_command_t *cmd, |
23 void *conf); | 23 void *conf); |
24 static char *ngx_set_worker_processes(ngx_conf_t *cf, ngx_command_t *cmd, | |
25 void *conf); | |
24 | 26 |
25 | 27 |
26 static ngx_conf_enum_t ngx_debug_points[] = { | 28 static ngx_conf_enum_t ngx_debug_points[] = { |
27 { ngx_string("stop"), NGX_DEBUG_POINTS_STOP }, | 29 { ngx_string("stop"), NGX_DEBUG_POINTS_STOP }, |
28 { ngx_string("abort"), NGX_DEBUG_POINTS_ABORT }, | 30 { ngx_string("abort"), NGX_DEBUG_POINTS_ABORT }, |
67 offsetof(ngx_core_conf_t, lock_file), | 69 offsetof(ngx_core_conf_t, lock_file), |
68 NULL }, | 70 NULL }, |
69 | 71 |
70 { ngx_string("worker_processes"), | 72 { ngx_string("worker_processes"), |
71 NGX_MAIN_CONF|NGX_DIRECT_CONF|NGX_CONF_TAKE1, | 73 NGX_MAIN_CONF|NGX_DIRECT_CONF|NGX_CONF_TAKE1, |
72 ngx_conf_set_num_slot, | 74 ngx_set_worker_processes, |
73 0, | 75 0, |
74 offsetof(ngx_core_conf_t, worker_processes), | 76 0, |
75 NULL }, | 77 NULL }, |
76 | 78 |
77 { ngx_string("debug_points"), | 79 { ngx_string("debug_points"), |
78 NGX_MAIN_CONF|NGX_DIRECT_CONF|NGX_CONF_TAKE1, | 80 NGX_MAIN_CONF|NGX_DIRECT_CONF|NGX_CONF_TAKE1, |
79 ngx_conf_set_enum_slot, | 81 ngx_conf_set_enum_slot, |
1327 return ccf->cpu_affinity[n]; | 1329 return ccf->cpu_affinity[n]; |
1328 } | 1330 } |
1329 | 1331 |
1330 return ccf->cpu_affinity[ccf->cpu_affinity_n - 1]; | 1332 return ccf->cpu_affinity[ccf->cpu_affinity_n - 1]; |
1331 } | 1333 } |
1334 | |
1335 | |
1336 static char * | |
1337 ngx_set_worker_processes(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) | |
1338 { | |
1339 ngx_str_t *value; | |
1340 ngx_core_conf_t *ccf; | |
1341 | |
1342 ccf = (ngx_core_conf_t *) conf; | |
1343 | |
1344 if (ccf->worker_processes != NGX_CONF_UNSET) { | |
1345 return "is duplicate"; | |
1346 } | |
1347 | |
1348 value = (ngx_str_t *) cf->args->elts; | |
1349 | |
1350 if (ngx_strcmp(value[1].data, "auto") == 0) { | |
1351 ccf->worker_processes = ngx_ncpu; | |
1352 return NGX_CONF_OK; | |
1353 } | |
1354 | |
1355 ccf->worker_processes = ngx_atoi(value[1].data, value[1].len); | |
1356 | |
1357 if (ccf->worker_processes == NGX_ERROR) { | |
1358 return "invalid value"; | |
1359 } | |
1360 | |
1361 return NGX_CONF_OK; | |
1362 } |