Skip to content

Commit

Permalink
make error messages more consistent
Browse files Browse the repository at this point in the history
  • Loading branch information
tony2001 committed Dec 16, 2009
1 parent 952efe8 commit 0901af0
Show file tree
Hide file tree
Showing 9 changed files with 68 additions and 63 deletions.
18 changes: 9 additions & 9 deletions sapi/fpm/fpm/fpm_children.c
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ static void fpm_child_init(struct fpm_worker_pool_s *wp) /* {{{ */
0 > fpm_env_init_child(wp) ||
0 > fpm_php_init_child(wp)) {

zlog(ZLOG_STUFF, ZLOG_ERROR, "child failed to initialize (pool %s)", wp->config->name);
zlog(ZLOG_STUFF, ZLOG_ERROR, "[pool %s] child failed to initialize", wp->config->name);
exit(255);
}
}
Expand Down Expand Up @@ -241,9 +241,9 @@ void fpm_children_bury() /* {{{ */
timersub(&tv1, &child->started, &tv2);

if (restart_child) {
zlog(ZLOG_STUFF, severity, "child %d (pool %s) exited %s after %ld.%06d seconds from start", (int) pid, child->wp->config->name, buf, tv2.tv_sec, (int) tv2.tv_usec);
zlog(ZLOG_STUFF, severity, "[pool %s] child %d exited %s after %ld.%06d seconds from start", child->wp->config->name, (int) pid, buf, tv2.tv_sec, (int) tv2.tv_usec);
} else {
zlog(ZLOG_STUFF, severity, "child %d (pool %s) has been killed by the process managment after %ld.%06d seconds from start", (int) pid, child->wp->config->name, tv2.tv_sec, (int) tv2.tv_usec);
zlog(ZLOG_STUFF, ZLOG_DEBUG, "[pool %s] child %d has been killed by the process managment after %ld.%06d seconds from start", child->wp->config->name, (int) pid, tv2.tv_sec, (int) tv2.tv_usec);
}

fpm_child_close(child, 1 /* in event_loop */);
Expand Down Expand Up @@ -277,7 +277,7 @@ void fpm_children_bury() /* {{{ */
}

if (restart_child) {
fpm_children_make(wp, 1 /* in event loop */, 1);
fpm_children_make(wp, 1 /* in event loop */, 1, 0);

if (fpm_globals.is_child) {
break;
Expand All @@ -297,7 +297,7 @@ static struct fpm_child_s *fpm_resources_prepare(struct fpm_worker_pool_s *wp) /
c = fpm_child_alloc();

if (!c) {
zlog(ZLOG_STUFF, ZLOG_ERROR, "malloc failed (pool %s)", wp->config->name);
zlog(ZLOG_STUFF, ZLOG_ERROR, "[pool %s] malloc failed", wp->config->name);
return 0;
}

Expand Down Expand Up @@ -343,15 +343,15 @@ static void fpm_parent_resources_use(struct fpm_child_s *child) /* {{{ */
}
/* }}} */

int fpm_children_make(struct fpm_worker_pool_s *wp, int in_event_loop, int nb_to_spawn) /* {{{ */
int fpm_children_make(struct fpm_worker_pool_s *wp, int in_event_loop, int nb_to_spawn, int is_debug) /* {{{ */
{
int enough = 0;
pid_t pid;
struct fpm_child_s *child;
int max;

if (wp->config->pm->style == PM_STYLE_DYNAMIC) {
if (!in_event_loop) { /* stating */
if (!in_event_loop) { /* starting */
max = wp->config->pm->dynamic.start_servers;
} else {
max = wp->running_children + nb_to_spawn;
Expand Down Expand Up @@ -394,7 +394,7 @@ int fpm_children_make(struct fpm_worker_pool_s *wp, int in_event_loop, int nb_to
fpm_clock_get(&child->started);
fpm_parent_resources_use(child);

zlog(ZLOG_STUFF, ZLOG_NOTICE, "child %d (pool %s) started", (int) pid, wp->config->name);
zlog(ZLOG_STUFF, is_debug ? ZLOG_DEBUG : ZLOG_NOTICE, "[pool %s] child %d started", wp->config->name, (int) pid);
}

}
Expand All @@ -405,7 +405,7 @@ int fpm_children_make(struct fpm_worker_pool_s *wp, int in_event_loop, int nb_to

int fpm_children_create_initial(struct fpm_worker_pool_s *wp) /* {{{ */
{
return fpm_children_make(wp, 0 /* not in event loop yet */, 0);
return fpm_children_make(wp, 0 /* not in event loop yet */, 0, 1);
}
/* }}} */

Expand Down
2 changes: 1 addition & 1 deletion sapi/fpm/fpm/fpm_children.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ int fpm_children_create_initial(struct fpm_worker_pool_s *wp);
int fpm_children_free(struct fpm_child_s *child);
void fpm_children_bury();
int fpm_children_init_main();
int fpm_children_make(struct fpm_worker_pool_s *wp, int in_event_loop, int nb_to_spawn);
int fpm_children_make(struct fpm_worker_pool_s *wp, int in_event_loop, int nb_to_spawn, int is_debug);

struct fpm_child_s;

Expand Down
18 changes: 9 additions & 9 deletions sapi/fpm/fpm/fpm_conf.c
Original file line number Diff line number Diff line change
Expand Up @@ -392,40 +392,40 @@ static int fpm_conf_process_all_pools() /* {{{ */
}

if (wp->config->pm == NULL) {
zlog(ZLOG_STUFF, ZLOG_ALERT, "pool %s: the process manager is missing (static or dynamic)", wp->config->name);
zlog(ZLOG_STUFF, ZLOG_ALERT, "[pool %s] the process manager is missing (static or dynamic)", wp->config->name);
return(-1);
}

if (wp->config->pm->style == PM_STYLE_DYNAMIC) {
struct fpm_pm_s *pm = wp->config->pm;

if (pm->dynamic.min_spare_servers <= 0) {
zlog(ZLOG_STUFF, ZLOG_ALERT, "pool %s: min_spare_servers must be a positive value", wp->config->name);
zlog(ZLOG_STUFF, ZLOG_ALERT, "[pool %s] min_spare_servers(%d) must be a positive value", wp->config->name, pm->dynamic.min_spare_servers);
return(-1);
}

if (pm->dynamic.max_spare_servers <= 0) {
zlog(ZLOG_STUFF, ZLOG_ALERT, "pool %s: max_spare_servers must be a positive value", wp->config->name);
zlog(ZLOG_STUFF, ZLOG_ALERT, "[pool %s] max_spare_servers(%d) must be a positive value", wp->config->name, pm->dynamic.max_spare_servers);
return(-1);
}

if (pm->dynamic.min_spare_servers > pm->max_children ||
pm->dynamic.max_spare_servers > pm->max_children) {
zlog(ZLOG_STUFF, ZLOG_ALERT, "pool %s: min_spare_servers(%d) and max_spare_servers(%d) can't be greater than max_children(%d)",
zlog(ZLOG_STUFF, ZLOG_ALERT, "[pool %s] min_spare_servers(%d) and max_spare_servers(%d) cannot be greater than max_children(%d)",
wp->config->name, pm->dynamic.min_spare_servers, pm->dynamic.max_spare_servers, pm->max_children);
return(-1);
}

if (pm->dynamic.max_spare_servers < pm->dynamic.min_spare_servers) {
zlog(ZLOG_STUFF, ZLOG_ALERT, "pool %s: max_spare_servers must be greater or equal than min_spare_servers", wp->config->name);
zlog(ZLOG_STUFF, ZLOG_ALERT, "[pool %s] max_spare_servers(%d) must not be less than min_spare_servers(%d)", wp->config->name, pm->dynamic.max_spare_servers, pm->dynamic.min_spare_servers);
return(-1);
}

if (pm->dynamic.start_servers <= 0) {
pm->dynamic.start_servers = pm->dynamic.min_spare_servers + ((pm->dynamic.max_spare_servers - pm->dynamic.min_spare_servers) / 2);
zlog(ZLOG_STUFF, ZLOG_NOTICE, "pool %s: start_servers has been set to %d", wp->config->name, pm->dynamic.start_servers);
zlog(ZLOG_STUFF, ZLOG_NOTICE, "[pool %s] start_servers has been set to %d", wp->config->name, pm->dynamic.start_servers);
} else if (pm->dynamic.start_servers < pm->dynamic.min_spare_servers || pm->dynamic.start_servers > pm->dynamic.max_spare_servers) {
zlog(ZLOG_STUFF, ZLOG_ALERT, "pool %s: start_servers must not be less than min_spare_servers and not greaters than max_spare_servers", wp->config->name);
zlog(ZLOG_STUFF, ZLOG_ALERT, "[pool %s] start_servers(%d) must not be less than min_spare_servers(%d) and not greater than max_spare_servers(%d)", wp->config->name, pm->dynamic.start_servers, pm->dynamic.min_spare_servers, pm->dynamic.max_spare_servers);
return(-1);
}
}
Expand All @@ -434,15 +434,15 @@ static int fpm_conf_process_all_pools() /* {{{ */
if (wp->config->request_slowlog_timeout) {
#if HAVE_FPM_TRACE
if (! (wp->config->slowlog && *wp->config->slowlog)) {
zlog(ZLOG_STUFF, ZLOG_ERROR, "pool %s: 'slowlog' must be specified for use with 'request_slowlog_timeout'",
zlog(ZLOG_STUFF, ZLOG_ERROR, "[pool %s] 'slowlog' must be specified for use with 'request_slowlog_timeout'",
wp->config->name);
return -1;
}
#else
static int warned = 0;

if (!warned) {
zlog(ZLOG_STUFF, ZLOG_WARNING, "pool %s: 'request_slowlog_timeout' is not supported on your system",
zlog(ZLOG_STUFF, ZLOG_WARNING, "[pool %s] 'request_slowlog_timeout' is not supported on your system",
wp->config->name);
warned = 1;
}
Expand Down
20 changes: 13 additions & 7 deletions sapi/fpm/fpm/fpm_events.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,29 +45,35 @@ static void fpm_got_signal(int fd, short ev, void *arg) /* {{{ */

switch (c) {
case 'C' : /* SIGCHLD */
zlog(ZLOG_STUFF, ZLOG_NOTICE, "received SIGCHLD");
zlog(ZLOG_STUFF, ZLOG_DEBUG, "received SIGCHLD");
fpm_children_bury();
break;
case 'I' : /* SIGINT */
zlog(ZLOG_STUFF, ZLOG_NOTICE, "received SIGINT");
zlog(ZLOG_STUFF, ZLOG_DEBUG, "received SIGINT");
zlog(ZLOG_STUFF, ZLOG_NOTICE, "Terminating ...");
fpm_pctl(FPM_PCTL_STATE_TERMINATING, FPM_PCTL_ACTION_SET);
break;
case 'T' : /* SIGTERM */
zlog(ZLOG_STUFF, ZLOG_NOTICE, "received SIGTERM");
zlog(ZLOG_STUFF, ZLOG_DEBUG, "received SIGTERM");
zlog(ZLOG_STUFF, ZLOG_NOTICE, "Terminating ...");
fpm_pctl(FPM_PCTL_STATE_TERMINATING, FPM_PCTL_ACTION_SET);
break;
case 'Q' : /* SIGQUIT */
zlog(ZLOG_STUFF, ZLOG_NOTICE, "received SIGQUIT");
zlog(ZLOG_STUFF, ZLOG_DEBUG, "received SIGQUIT");
zlog(ZLOG_STUFF, ZLOG_NOTICE, "Finishing ...");
fpm_pctl(FPM_PCTL_STATE_FINISHING, FPM_PCTL_ACTION_SET);
break;
case '1' : /* SIGUSR1 */
zlog(ZLOG_STUFF, ZLOG_NOTICE, "received SIGUSR1");
zlog(ZLOG_STUFF, ZLOG_DEBUG, "received SIGUSR1");
if (0 == fpm_stdio_open_error_log(1)) {
zlog(ZLOG_STUFF, ZLOG_NOTICE, "log file re-opened");
} else {
zlog(ZLOG_STUFF, ZLOG_ERROR, "unable to re-opened log file");
}
break;
case '2' : /* SIGUSR2 */
zlog(ZLOG_STUFF, ZLOG_NOTICE, "received SIGUSR2");
zlog(ZLOG_STUFF, ZLOG_DEBUG, "received SIGUSR2");
zlog(ZLOG_STUFF, ZLOG_NOTICE, "Reloading in progress ...");
fpm_pctl(FPM_PCTL_STATE_RELOADING, FPM_PCTL_ACTION_SET);
break;
}
Expand Down Expand Up @@ -101,7 +107,7 @@ int fpm_event_loop() /* {{{ */
event_add(&signal_fd_event, 0);
fpm_pctl_heartbeat(-1, 0, 0);
fpm_pctl_perform_idle_server_maintenance_heartbeat(-1, 0, 0);
zlog(ZLOG_STUFF, ZLOG_NOTICE, "libevent: entering main loop");
zlog(ZLOG_STUFF, ZLOG_NOTICE, "ready to handle connections");
event_loop(0);
return 0;
}
Expand Down
2 changes: 1 addition & 1 deletion sapi/fpm/fpm/fpm_php_trace.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ static int fpm_php_trace_dump(struct fpm_child_s *child, FILE *slowlog TSRMLS_DC

zlog_print_time(&tv, buf, buf_size);

fprintf(slowlog, "\n%s pid %d (pool %s)\n", buf, (int) pid, child->wp->config->name);
fprintf(slowlog, "\n%s [pool %s] pid %d\n", buf, child->wp->config->name, (int) pid);

if (0 > fpm_trace_get_strz(buf, buf_size, (long) &SG(request_info).path_translated)) {
return -1;
Expand Down
21 changes: 10 additions & 11 deletions sapi/fpm/fpm/fpm_process_ctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,9 @@ static void fpm_pctl_kill_all(int signo) /* {{{ */
for (child = wp->children; child; child = child->next) {
int res = kill(child->pid, signo);

zlog(ZLOG_STUFF, ZLOG_NOTICE, "sending signal %d %s to child %d (pool %s)", signo,
fpm_signal_names[signo] ? fpm_signal_names[signo] : "",
(int) child->pid, child->wp->config->name);
zlog(ZLOG_STUFF, ZLOG_NOTICE, "[pool %s] sending signal %d %s to child %d",
child->wp->config->name, signo,
fpm_signal_names[signo] ? fpm_signal_names[signo] : "", (int) child->pid);

if (res == 0) {
++alive_children;
Expand All @@ -168,7 +168,7 @@ static void fpm_pctl_kill_all(int signo) /* {{{ */
}

if (alive_children) {
zlog(ZLOG_STUFF, ZLOG_NOTICE, "%d %s still alive", alive_children, alive_children == 1 ? "child is" : "children are");
zlog(ZLOG_STUFF, ZLOG_NOTICE, "%d child(ren) still alive", alive_children);
}
}
/* }}} */
Expand Down Expand Up @@ -340,10 +340,10 @@ static void fpm_pctl_perform_idle_server_maintenance(struct timeval *now) /* {{{
}
}

zlog(ZLOG_STUFF, ZLOG_DEBUG, "[%s] rate=%d idle=%d active=%d total=%d", wp->config->name, wp->idle_spawn_rate, idle, active, wp->running_children);
zlog(ZLOG_STUFF, ZLOG_DEBUG, "[pool %s] currently %d active children, %d spare children, %d running children. Spawning rate %d", wp->config->name, active, idle, wp->running_children, wp->idle_spawn_rate);

if ((active + idle) != wp->running_children) {
zlog(ZLOG_STUFF, ZLOG_ERROR, "[%s] unable to retrieve spawning informations", wp->config->name);
zlog(ZLOG_STUFF, ZLOG_ERROR, "[pool %s] unable to retrieve process activiry of one or more child(ren). Will try again later.", wp->config->name);
continue;
}

Expand All @@ -357,8 +357,7 @@ static void fpm_pctl_perform_idle_server_maintenance(struct timeval *now) /* {{{
if (idle < wp->config->pm->dynamic.min_spare_servers) {
if (wp->running_children >= wp->config->pm->max_children) {
if (!wp->warn_max_children) {
zlog(ZLOG_STUFF, ZLOG_WARNING, "pool %s: server reached max_children setting, consider raising it",
wp->config->name);
zlog(ZLOG_STUFF, ZLOG_WARNING, "[pool %s] server reached max_children setting (%d), consider raising it", wp->config->name, wp->config->pm->max_children);
wp->warn_max_children = 1;
}
wp->idle_spawn_rate = 1;
Expand All @@ -367,11 +366,11 @@ static void fpm_pctl_perform_idle_server_maintenance(struct timeval *now) /* {{{
wp->warn_max_children = 0;

if (wp->idle_spawn_rate >= 8) {
zlog(ZLOG_STUFF, ZLOG_WARNING, "pool %s seems busy (you may need to increase start_servers, or min/max_spare_servers), spawning %d children, there are %d idle, and %d total children", wp->config->name, wp->idle_spawn_rate, idle, wp->running_children);
zlog(ZLOG_STUFF, ZLOG_WARNING, "[pool %s] seems busy (you may need to increase start_servers, or min/max_spare_servers), spawning %d children, there are %d idle, and %d total children", wp->config->name, wp->idle_spawn_rate, idle, wp->running_children);
}

i = MIN(wp->idle_spawn_rate, wp->config->pm->dynamic.min_spare_servers - idle);
fpm_children_make(wp, 1, i);
fpm_children_make(wp, 1, i, 1);

/* if it's a child, stop here without creating the next event
* this event is reserved to the master process
Expand All @@ -380,7 +379,7 @@ static void fpm_pctl_perform_idle_server_maintenance(struct timeval *now) /* {{{
return;
}

zlog(ZLOG_STUFF, ZLOG_NOTICE, "pool %s: %d child(ren) have been created because of not enough spare children", wp->config->name, i);
zlog(ZLOG_STUFF, ZLOG_DEBUG, "[pool %s] %d child(ren) have been created dynamically", wp->config->name, i);

/* Double the spawn rate for the next iteration */
if (wp->idle_spawn_rate < FPM_MAX_SPAWN_RATE) {
Expand Down
8 changes: 4 additions & 4 deletions sapi/fpm/fpm/fpm_request.c
Original file line number Diff line number Diff line change
Expand Up @@ -132,17 +132,17 @@ void fpm_request_check_timed_out(struct fpm_child_s *child, struct timeval *now,

fpm_trace_signal(child->pid);

zlog(ZLOG_STUFF, ZLOG_WARNING, "child %d, script '%s' (pool %s) executing too slow (%d.%06d sec), logging",
(int) child->pid, purified_script_filename, child->wp->config->name, (int) tv.tv_sec, (int) tv.tv_usec);
zlog(ZLOG_STUFF, ZLOG_WARNING, "[pool %s] child %d, script '%s' executing too slow (%d.%06d sec), logging",
child->wp->config->name, (int) child->pid, purified_script_filename, (int) tv.tv_sec, (int) tv.tv_usec);
}
else
#endif
if (terminate_timeout && tv.tv_sec >= terminate_timeout) {
str_purify_filename(purified_script_filename, slot_c.script_filename, sizeof(slot_c.script_filename));
fpm_pctl_kill(child->pid, FPM_PCTL_TERM);

zlog(ZLOG_STUFF, ZLOG_WARNING, "child %d, script '%s' (pool %s) execution timed out (%d.%06d sec), terminating",
(int) child->pid, purified_script_filename, child->wp->config->name, (int) tv.tv_sec, (int) tv.tv_usec);
zlog(ZLOG_STUFF, ZLOG_WARNING, "[pool %s] child %d, script '%s' execution timed out (%d.%06d sec), terminating",
child->wp->config->name, (int) child->pid, purified_script_filename, (int) tv.tv_sec, (int) tv.tv_usec);
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions sapi/fpm/fpm/fpm_stdio.c
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,8 @@ static void fpm_stdio_child_said(int fd, short which, void *arg) /* {{{ */

#if 0
if (in_buf == 0 && !fpm_globals.is_child) {
zlog(ZLOG_STUFF, ZLOG_DEBUG, "child %d (pool %s) %s pipe is closed", (int) child->pid,
child->wp->config->name, is_stdout ? "stdout" : "stderr");
zlog(ZLOG_STUFF, ZLOG_DEBUG, "[pool %s] child %d, %s pipe is closed", child->wp->config->name,
(int) child->pid, is_stdout ? "stdout" : "stderr");
}
#endif
}
Expand Down Expand Up @@ -151,8 +151,8 @@ static void fpm_stdio_child_said(int fd, short which, void *arg) /* {{{ */
*nl = '\0';
}

zlog(ZLOG_STUFF, ZLOG_WARNING, "child %d (pool %s) said into %s: \"%s\"%s", (int) child->pid,
child->wp->config->name, is_stdout ? "stdout" : "stderr", buf, is_last_message ? ", pipe is closed" : "");
zlog(ZLOG_STUFF, ZLOG_WARNING, "[pool %s] child %d said into %s: \"%s\"%s", child->wp->config->name,
(int) child->pid, is_stdout ? "stdout" : "stderr", buf, is_last_message ? ", pipe is closed" : "");

if (nl) {
int out_buf = 1 + nl - buf;
Expand Down
Loading

0 comments on commit 0901af0

Please sign in to comment.