MINOR: startup: display the path and version of haproxy

Instead of using the first ha_alert or ha_notice message shown, display
the haproxy version at startup.
This commit is contained in:
William Lallemand 2024-01-31 22:11:08 +01:00
parent f40defae7f
commit 7b0d47c41a
2 changed files with 6 additions and 23 deletions

View File

@ -413,29 +413,10 @@ static void print_message(int use_usermsgs_ctx, const char *label, const char *f
free(msg);
}
static void print_message_args(int use_usermsgs_ctx, const char *label, const char *fmt, ...)
{
va_list argp;
va_start(argp, fmt);
print_message(use_usermsgs_ctx, label, fmt, argp);
va_end(argp);
}
/*
* Display a notice with the happroxy version and executable path when the
* first message is emitted in starting mode.
*/
static void warn_exec_path()
{
if (!(warned & WARN_EXEC_PATH) && (global.mode & MODE_STARTING)) {
const char *path = get_exec_path();
warned |= WARN_EXEC_PATH;
print_message_args(0, "NOTICE", "haproxy version is %s\n", haproxy_version);
if (path)
print_message_args(0, "NOTICE", "path to executable is %s\n", path);
}
}
/*
* Displays the message on stderr with the pid.
@ -444,7 +425,6 @@ void ha_alert(const char *fmt, ...)
{
va_list argp;
warn_exec_path();
va_start(argp, fmt);
print_message(1, "ALERT", fmt, argp);
va_end(argp);
@ -460,7 +440,6 @@ void ha_warning(const char *fmt, ...)
warned |= WARN_ANY;
HA_ATOMIC_INC(&tot_warnings);
warn_exec_path();
va_start(argp, fmt);
print_message(1, "WARNING", fmt, argp);
va_end(argp);

View File

@ -829,7 +829,7 @@ void mworker_reload(int hardreload)
struct mworker_proc *child;
struct per_thread_deinit_fct *ptdf;
ha_notice("Reloading HAProxy%s\n", hardreload?" (hard-reload)":"");
ha_notice("Reloading HAProxy%s...\n", hardreload?" (hard-reload)":"");
/* close the poller FD and the thread waker pipe FD */
list_for_each_entry(ptdf, &per_thread_deinit_list, list)
@ -2114,13 +2114,14 @@ static void init(int argc, char **argv)
exit(result ? 0 : 1);
}
if (global.mode & MODE_MWORKER) {
struct mworker_proc *tmproc;
setenv("HAPROXY_MWORKER", "1", 1);
if (getenv("HAPROXY_MWORKER_REEXEC") == NULL) {
ha_notice("Starting HAProxy version '%s' from path '%s'\n", haproxy_version, get_exec_path());
tmproc = mworker_proc_new();
if (!tmproc) {
ha_alert("Cannot allocate process structures.\n");
@ -2132,6 +2133,8 @@ static void init(int argc, char **argv)
proc_self = tmproc;
LIST_APPEND(&proc_list, &tmproc->list);
} else {
ha_notice("Reloading HAProxy version '%s' from path '%s'\n", haproxy_version, get_exec_path());
}
tmproc = mworker_proc_new();
@ -2870,6 +2873,7 @@ void deinit(void)
return;
/* At this point the listeners state is weird:
* - most listeners are still bound and referenced in their protocol
* - some might be zombies that are not in their proto anymore, but
* still appear in their proxy's listeners with a valid FD.