From 86475993fe0c5d63364cdd1c0fdfdd654bd53e50 Mon Sep 17 00:00:00 2001 From: Hiroshi Hatake Date: Fri, 6 Oct 2023 05:04:13 +0900 Subject: [PATCH] http_server: v2: reload: windows: Enable hot reloading (#7984) Building on top of calyptia-fleet works on Windows, we can also offer for enabling hot-reloading on Windows. :) Signed-off-by: Hiroshi Hatake --- src/http_server/api/v2/reload.c | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/src/http_server/api/v2/reload.c b/src/http_server/api/v2/reload.c index 3bb5159fa57..c158fca8ba5 100644 --- a/src/http_server/api/v2/reload.c +++ b/src/http_server/api/v2/reload.c @@ -50,13 +50,27 @@ static void handle_reload_request(mk_request_t *request, struct flb_config *conf msgpack_pack_str_body(&mp_pck, "reload", 6); #ifdef FLB_SYSTEM_WINDOWS - ret = -1; + if (config->enable_hot_reload != FLB_TRUE) { + msgpack_pack_str(&mp_pck, 11); + msgpack_pack_str_body(&mp_pck, "not enabled", 11); + msgpack_pack_str(&mp_pck, 6); + msgpack_pack_str_body(&mp_pck, "status", 6); + msgpack_pack_int64(&mp_pck, -1); + } + else { + ret = GenerateConsoleCtrlEvent(1 /* CTRL_BREAK_EVENT_1 */, 0); + if (ret == 0) { + mk_http_status(request, 500); + mk_http_done(request); + return; + } - msgpack_pack_str(&mp_pck, 11); - msgpack_pack_str_body(&mp_pck, "unsupported", 11); - msgpack_pack_str(&mp_pck, 6); - msgpack_pack_str_body(&mp_pck, "status", 6); - msgpack_pack_int64(&mp_pck, ret); + msgpack_pack_str(&mp_pck, 4); + msgpack_pack_str_body(&mp_pck, "done", 4); + msgpack_pack_str(&mp_pck, 6); + msgpack_pack_str_body(&mp_pck, "status", 6); + msgpack_pack_int64(&mp_pck, ret); + } #else if (config->enable_hot_reload != FLB_TRUE) { msgpack_pack_str(&mp_pck, 11);