summaryrefslogtreecommitdiffstats
path: root/daemon/signals.c
diff options
context:
space:
mode:
authorMarkos Fountoulakis <44345837+mfundul@users.noreply.github.com>2019-12-05 00:21:22 +0200
committerChris Akritidis <43294513+cakrit@users.noreply.github.com>2019-12-04 14:21:22 -0800
commit16f835489c1a93b5dbd84747c52c883f43b716f0 (patch)
treefe91de0b4fa0d85f52870550e410bc1d0dead434 /daemon/signals.c
parenta7a88ba2723242da1de6626df0541d2091bd9b2b (diff)
Implement netdata command server and cli tool (#7325)
* Checkpoint commit (POC) * Implemented command server in the daemon * Add netdatacli implementation * Added prints in command server setup functions * Make libuv version 1 a hard dependency for the agent * Additional documentation * Improved accuracy of names and documentation * Fixed documentation * Fixed buffer overflow * Added support for exit status in cli. Added prefixes for exit code, stdout and stderr. Fixed parsers. * Fix compilation errors * Fix compile errors * Fix compile errors * Fix compile error * Fix linker error for muslc
Diffstat (limited to 'daemon/signals.c')
-rw-r--r--daemon/signals.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/daemon/signals.c b/daemon/signals.c
index 5378b04e5e..d4e74614f7 100644
--- a/daemon/signals.c
+++ b/daemon/signals.c
@@ -9,7 +9,7 @@ typedef enum signal_action {
NETDATA_SIGNAL_IGNORE,
NETDATA_SIGNAL_EXIT_CLEANLY,
NETDATA_SIGNAL_SAVE_DATABASE,
- NETDATA_SIGNAL_LOG_ROTATE,
+ NETDATA_SIGNAL_REOPEN_LOGS,
NETDATA_SIGNAL_RELOAD_HEALTH,
NETDATA_SIGNAL_FATAL,
NETDATA_SIGNAL_CHILD,
@@ -25,7 +25,7 @@ static struct {
{ SIGINT , "SIGINT", 0, NETDATA_SIGNAL_EXIT_CLEANLY },
{ SIGQUIT, "SIGQUIT", 0, NETDATA_SIGNAL_EXIT_CLEANLY },
{ SIGTERM, "SIGTERM", 0, NETDATA_SIGNAL_EXIT_CLEANLY },
- { SIGHUP, "SIGHUP", 0, NETDATA_SIGNAL_LOG_ROTATE },
+ { SIGHUP, "SIGHUP", 0, NETDATA_SIGNAL_REOPEN_LOGS },
{ SIGUSR1, "SIGUSR1", 0, NETDATA_SIGNAL_SAVE_DATABASE },
{ SIGUSR2, "SIGUSR2", 0, NETDATA_SIGNAL_RELOAD_HEALTH },
{ SIGBUS, "SIGBUS", 0, NETDATA_SIGNAL_FATAL },
@@ -221,33 +221,35 @@ void signals_handle(void) {
case NETDATA_SIGNAL_RELOAD_HEALTH:
error_log_limit_unlimited();
info("SIGNAL: Received %s. Reloading HEALTH configuration...", name);
- health_reload();
error_log_limit_reset();
+ execute_command(CMD_RELOAD_HEALTH, NULL, NULL);
break;
case NETDATA_SIGNAL_SAVE_DATABASE:
error_log_limit_unlimited();
info("SIGNAL: Received %s. Saving databases...", name);
- rrdhost_save_all();
- info("Databases saved.");
error_log_limit_reset();
+ execute_command(CMD_SAVE_DATABASE, NULL, NULL);
break;
- case NETDATA_SIGNAL_LOG_ROTATE:
+ case NETDATA_SIGNAL_REOPEN_LOGS:
error_log_limit_unlimited();
info("SIGNAL: Received %s. Reopening all log files...", name);
- reopen_all_log_files();
error_log_limit_reset();
+ execute_command(CMD_REOPEN_LOGS, NULL, NULL);
break;
case NETDATA_SIGNAL_EXIT_CLEANLY:
error_log_limit_unlimited();
info("SIGNAL: Received %s. Cleaning up to exit...", name);
+ commands_exit();
netdata_cleanup_and_exit(0);
exit(0);
+ break;
case NETDATA_SIGNAL_FATAL:
fatal("SIGNAL: Received %s. netdata now exits.", name);
+ break;
case NETDATA_SIGNAL_CHILD:
debug(D_CHILDS, "SIGNAL: Received %s. Reaping...", name);