*/
void reexec_on_failure()
{
+ struct mworker_proc *child;
+
if (!atexit_flag)
return;
+
+ /* get the info of the children in the env */
+ if (mworker_env_to_proc_list() < 0) {
+ exit(EXIT_FAILURE);
+ }
+
+ /* increment the number of failed reloads */
+ list_for_each_entry(child, &proc_list, list) {
+ child->failedreloads++;
+ }
+
usermsgs_clr(NULL);
ha_warning("Loading failure!\n");
mworker_reexec_waitmode();
exit(EXIT_FAILURE);
}
tmproc->options |= PROC_O_TYPE_MASTER; /* master */
+ tmproc->failedreloads = 0;
tmproc->reloads = 0;
tmproc->pid = pid;
tmproc->timestamp = start_date.tv_sec;
tmproc->options |= PROC_O_TYPE_WORKER; /* worker */
tmproc->pid = -1;
+ tmproc->failedreloads = 0;
tmproc->reloads = 0;
tmproc->timestamp = -1;
tmproc->ipc_fd[0] = -1;
/* if not in wait mode, reload in wait mode to free the memory */
ha_notice("Loading success.\n");
+ proc_self->failedreloads = 0; /* reset the number of failure */
mworker_reexec_waitmode();
}
/* should never get there */
type = 'w';
if (child->pid > -1)
- memprintf(&msg, "%s|type=%c;fd=%d;pid=%d;reloads=%d;timestamp=%d;id=%s;version=%s", msg ? msg : "", type, child->ipc_fd[0], child->pid, child->reloads, child->timestamp, child->id ? child->id : "", child->version);
+ memprintf(&msg, "%s|type=%c;fd=%d;pid=%d;reloads=%d;failedreloads=%d;timestamp=%d;id=%s;version=%s", msg ? msg : "", type, child->ipc_fd[0], child->pid, child->reloads, child->failedreloads, child->timestamp, child->id ? child->id : "", child->version);
}
if (msg)
setenv("HAPROXY_PROCESSES", msg, 1);
} else if (strncmp(subtoken, "reloads=", 8) == 0) {
/* we only increment the number of asked reload */
child->reloads = atoi(subtoken+8);
+ } else if (strncmp(subtoken, "failedreloads=", 14) == 0) {
+ child->failedreloads = atoi(subtoken+14);
} else if (strncmp(subtoken, "timestamp=", 10) == 0) {
child->timestamp = atoi(subtoken+10);
} else if (strncmp(subtoken, "id=", 3) == 0) {
int old = 0;
int up = now.tv_sec - proc_self->timestamp;
char *uptime = NULL;
+ char *reloadtxt = NULL;
if (unlikely(si_ic(si)->flags & (CF_WRITE_ERROR|CF_SHUTW)))
return 1;
chunk_reset(&trash);
+ memprintf(&reloadtxt, "%d [failed: %d]", proc_self->reloads, proc_self->failedreloads);
chunk_printf(&trash, "#%-14s %-15s %-15s %-15s %-15s\n", "<PID>", "<type>", "<reloads>", "<uptime>", "<version>");
memprintf(&uptime, "%dd%02dh%02dm%02ds", up / 86400, (up % 86400) / 3600, (up % 3600) / 60, (up % 60));
- chunk_appendf(&trash, "%-15u %-15s %-15d %-15s %-15s\n", (unsigned int)getpid(), "master", proc_self->reloads, uptime, haproxy_version);
+ chunk_appendf(&trash, "%-15u %-15s %-15s %-15s %-15s\n", (unsigned int)getpid(), "master", reloadtxt, uptime, haproxy_version);
+ ha_free(&reloadtxt);
ha_free(&uptime);
/* displays current processes */