Skip to content

Commit

Permalink
api: v2: reload: Distinguish the status of hot reloading
Browse files Browse the repository at this point in the history
Signed-off-by: Hiroshi Hatake <[email protected]>
  • Loading branch information
cosmo0920 authored and edsiper committed Mar 14, 2024
1 parent 8eaaaa2 commit 8d24117
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion src/http_server/api/v2/reload.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ static void handle_reload_request(mk_request_t *request, struct flb_config *conf
size_t out_size;
msgpack_packer mp_pck;
msgpack_sbuffer mp_sbuf;
int http_status = 200;

/* initialize buffers */
msgpack_sbuffer_init(&mp_sbuf);
Expand All @@ -57,6 +58,14 @@ static void handle_reload_request(mk_request_t *request, struct flb_config *conf
msgpack_pack_str_body(&mp_pck, "status", 6);
msgpack_pack_int64(&mp_pck, -1);
}
else if (config->hot_reloading == FLB_TRUE) {
msgpack_pack_str(&mp_pck, 11);
msgpack_pack_str_body(&mp_pck, "in progress", 11);
msgpack_pack_str(&mp_pck, 6);
msgpack_pack_str_body(&mp_pck, "status", 6);
msgpack_pack_int64(&mp_pck, -2);
http_status = 400;
}
else {
ret = GenerateConsoleCtrlEvent(1 /* CTRL_BREAK_EVENT_1 */, 0);
if (ret == 0) {
Expand All @@ -79,6 +88,14 @@ static void handle_reload_request(mk_request_t *request, struct flb_config *conf
msgpack_pack_str_body(&mp_pck, "status", 6);
msgpack_pack_int64(&mp_pck, -1);
}
else if (config->hot_reloading == FLB_TRUE) {
msgpack_pack_str(&mp_pck, 11);
msgpack_pack_str_body(&mp_pck, "in progress", 11);
msgpack_pack_str(&mp_pck, 6);
msgpack_pack_str_body(&mp_pck, "status", 6);
msgpack_pack_int64(&mp_pck, -2);
http_status = 400;
}
else {
ret = kill(getpid(), SIGHUP);
if (ret != 0) {
Expand Down Expand Up @@ -106,7 +123,7 @@ static void handle_reload_request(mk_request_t *request, struct flb_config *conf
}
out_size = flb_sds_len(out_buf);

mk_http_status(request, 200);
mk_http_status(request, http_status);
flb_hs_add_content_type_to_req(request, FLB_HS_CONTENT_TYPE_JSON);
mk_http_send(request, out_buf, out_size, NULL);
mk_http_done(request);
Expand Down

0 comments on commit 8d24117

Please sign in to comment.