mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-09-25 07:41:36 +02:00
BUG/MINOR: mworker: show worker warnings in startup logs
As master-worker fork happens now at early init stage and worker then parses its configuration and performs all initialization steps, let's duplicate startup logs ring for it, just before the moment when it enters in its pollong loop. Startup logs ring content is shown as an output of the "reload" master CLI command and we should be able to dump here worker initialization logs. Log messages are written in startup logs ring only, when mode MODE_STARTING is set (see print_message()). So, to be able to keep in startup logs the last worker alerts, let's withdraw MODE_STARTING and let's reset user messages context respectively just before entering in polling loop. This fix does not need to be backported as it is a part of previous patches from this version, which refactor master-worker architecture.
This commit is contained in:
parent
5ee266b745
commit
4db0f69527
@ -2136,7 +2136,6 @@ static void apply_master_worker_mode()
|
||||
{
|
||||
int worker_pid;
|
||||
struct mworker_proc *child;
|
||||
struct ring *tmp_startup_logs = NULL;
|
||||
char *sock_name = NULL;
|
||||
|
||||
worker_pid = fork();
|
||||
@ -2146,12 +2145,6 @@ static void apply_master_worker_mode()
|
||||
|
||||
exit(EXIT_FAILURE);
|
||||
case 0:
|
||||
/* in child: at this point the worker must have his own startup_logs buffer */
|
||||
tmp_startup_logs = startup_logs_dup(startup_logs);
|
||||
if (tmp_startup_logs == NULL)
|
||||
exit(EXIT_FAILURE);
|
||||
startup_logs_free(startup_logs);
|
||||
startup_logs = tmp_startup_logs;
|
||||
/* This one must not be exported, it's internal! */
|
||||
unsetenv("HAPROXY_MWORKER_REEXEC");
|
||||
ha_random_jump96(1);
|
||||
@ -3664,6 +3657,7 @@ int main(int argc, char **argv)
|
||||
struct rlimit limit;
|
||||
int intovf = (unsigned char)argc + 1; /* let the compiler know it's strictly positive */
|
||||
struct cfgfile *cfg, *cfg_tmp;
|
||||
struct ring *tmp_startup_logs = NULL;
|
||||
|
||||
/* Catch broken toolchains */
|
||||
if (sizeof(long) != sizeof(void *) || (intovf + 0x7FFFFFFF >= intovf)) {
|
||||
@ -4041,8 +4035,6 @@ int main(int argc, char **argv)
|
||||
#endif
|
||||
}
|
||||
|
||||
global.mode &= ~MODE_STARTING;
|
||||
reset_usermsgs_ctx();
|
||||
|
||||
/* start threads 2 and above */
|
||||
setup_extra_threads(&run_thread_poll_loop);
|
||||
@ -4088,7 +4080,19 @@ int main(int argc, char **argv)
|
||||
}
|
||||
close(sock_pair[1]);
|
||||
ha_free(&msg);
|
||||
|
||||
/* at this point the worker must have his own startup_logs buffer */
|
||||
tmp_startup_logs = startup_logs_dup(startup_logs);
|
||||
if (tmp_startup_logs == NULL)
|
||||
exit(EXIT_FAILURE);
|
||||
startup_logs_free(startup_logs);
|
||||
startup_logs = tmp_startup_logs;
|
||||
}
|
||||
/* can't unset MODE_STARTING earlier, otherwise worker's last alerts
|
||||
* should be not written in startup logs.
|
||||
*/
|
||||
global.mode &= ~MODE_STARTING;
|
||||
reset_usermsgs_ctx();
|
||||
|
||||
/* Finally, start the poll loop for the first thread */
|
||||
run_thread_poll_loop(&ha_thread_info[0]);
|
||||
|
Loading…
x
Reference in New Issue
Block a user