diff --git a/src/mworker.c b/src/mworker.c index e613a4e16..40086da73 100644 --- a/src/mworker.c +++ b/src/mworker.c @@ -37,6 +37,7 @@ #include #include #include +#include #include #include #include @@ -657,29 +658,44 @@ static int cli_parse_reload(char **args, char *payload, struct appctx *appctx, v return 1; } -/* Displays if the current reload failed or succeed */ -static int cli_parse_status(char **args, char *payload, struct appctx *appctx, void *private) +/* Displays if the current reload failed or succeed. + * If the startup-logs is available, dump it. */ +static int cli_io_handler_show_status(struct appctx *appctx) { char *env; + struct stconn *sc = appctx_sc(appctx); if (!cli_has_level(appctx, ACCESS_LVL_OPER)) return 1; + if (unlikely(sc_ic(sc)->flags & (CF_WRITE_ERROR|CF_SHUTW))) + return 1; + + env = getenv("HAPROXY_LOAD_SUCCESS"); if (!env) return 1; if (strcmp(env, "0") == 0) { - return cli_msg(appctx, LOG_INFO, "Loading failure!\n"); + chunk_printf(&trash, "Success=0\n"); } else if (strcmp(env, "1") == 0) { - return cli_msg(appctx, LOG_INFO, "Loading success.\n"); + chunk_printf(&trash, "Success=1\n"); } + if (startup_logs && b_data(&startup_logs->buf) > 1) + chunk_appendf(&trash, "--\n"); + + if (applet_putchk(appctx, &trash) == -1) + return 0; + + if (startup_logs) { + appctx->io_handler = NULL; + ring_attach_cli(startup_logs, appctx, 0); + return 0; + } return 1; } - - static int mworker_parse_global_max_reloads(char **args, int section_type, struct proxy *curpx, const struct proxy *defpx, const char *file, int linenum, char **err) { @@ -737,7 +753,7 @@ static struct cli_kw_list cli_kws = {{ },{ { { "@master", NULL }, "@master : send a command to the master process", cli_parse_default, NULL, NULL, NULL, ACCESS_MASTER_ONLY}, { { "show", "proc", NULL }, "show proc : show processes status", cli_parse_default, cli_io_handler_show_proc, NULL, NULL, ACCESS_MASTER_ONLY}, { { "reload", NULL }, "reload : reload haproxy", cli_parse_reload, NULL, NULL, NULL, ACCESS_MASTER_ONLY}, - { { "_loadstatus", NULL }, NULL, cli_parse_status, NULL, NULL, NULL, ACCESS_MASTER_ONLY}, + { { "_loadstatus", NULL }, NULL, cli_parse_default, cli_io_handler_show_status, NULL, NULL, ACCESS_MASTER_ONLY}, {{},} }};