]> arthur.barton.de Git - netdata.git/blobdiff - src/main.c
Prepare release 1.3.0
[netdata.git] / src / main.c
index 9e4fdb43fcaa298db4dd5f9153459ed5ae84c221..4d55a1425d6a023a49e019b8897c3cf6a1db70c6 100644 (file)
@@ -209,7 +209,7 @@ struct option_def options[] = {
 Same as 'update every' config file option.",                                 "seconds",                              "1"},
     {'u', "System username to run as.",                                      "username",                             "netdata"},
     {'v', "Version of the program",                                          NULL,                                   NULL},
-    {'W', "vendor options.",                                                 "stacksize=<size>|unittest|debug_flag", NULL},
+    {'W', "vendor options.",                                                 "stacksize=N|unittest|debug_flags=N",   NULL},
 };
 
 void help(int exitcode) {
@@ -378,7 +378,7 @@ int main(int argc, char **argv)
                     break;
                 case 'v':
                     // TODO: Outsource version to makefile which can compute version from git.
-                    printf("netdata 1.2.1_master\n");
+                    printf("netdata 1.3.0\n");
                     return 0;
                 case 'W':
                     {
@@ -501,6 +501,7 @@ int main(int argc, char **argv)
                 error("WARNING: Cannot get machine hostname.");
             hostname = config_get("global", "hostname", hostnamebuf);
             debug(D_OPTIONS, "hostname set to '%s'", hostname);
+            setenv("NETDATA_HOSTNAME", hostname, 1);
         }
 
         // --------------------------------------------------------------------
@@ -536,50 +537,45 @@ int main(int argc, char **argv)
         // this causes the threads to block signals.
         sigset_t sigset;
         sigfillset(&sigset);
-
-        if(pthread_sigmask(SIG_BLOCK, &sigset, NULL) == -1) {
+        if(pthread_sigmask(SIG_BLOCK, &sigset, NULL) == -1)
             error("Could not block signals for threads");
-        }
 
         // Catch signals which we want to use
         struct sigaction sa;
-        sigemptyset(&sa.sa_mask);
-        sigaddset(&sa.sa_mask, SIGINT);
-        sigaddset(&sa.sa_mask, SIGTERM);
-        sa.sa_handler = sig_handler_exit;
         sa.sa_flags = 0;
-        if(sigaction(SIGINT, &sa, NULL) == -1) {
+
+        // ingore all signals while we run in a signal handler
+        sigfillset(&sa.sa_mask);
+
+        // INFO: If we add signals here we have to unblock them
+        // at popen.c when running a external plugin.
+
+        // Ignore SIGPIPE completely.
+        sa.sa_handler = SIG_IGN;
+        if(sigaction(SIGPIPE, &sa, NULL) == -1)
+            error("Failed to change signal handler for SIGPIPE");
+
+        sa.sa_handler = sig_handler_exit;
+        if(sigaction(SIGINT, &sa, NULL) == -1)
             error("Failed to change signal handler for SIGINT");
-        }
-        if(sigaction(SIGTERM, &sa, NULL) == -1) {
+
+        sa.sa_handler = sig_handler_exit;
+        if(sigaction(SIGTERM, &sa, NULL) == -1)
             error("Failed to change signal handler for SIGTERM");
-        }
 
-        sigemptyset(&sa.sa_mask);
-        sigaddset(&sa.sa_mask, SIGHUP);
         sa.sa_handler = sig_handler_logrotate;
-        sa.sa_flags = 0;
-        if(sigaction(SIGHUP, &sa, NULL) == -1) {
+        if(sigaction(SIGHUP, &sa, NULL) == -1)
             error("Failed to change signal handler for SIGHUP");
-        }
 
         // save database on SIGUSR1
-        sigemptyset(&sa.sa_mask);
-        sigaddset(&sa.sa_mask, SIGUSR1);
         sa.sa_handler = sig_handler_save;
-        if(sigaction(SIGUSR1, &sa, NULL) == -1) {
+        if(sigaction(SIGUSR1, &sa, NULL) == -1)
             error("Failed to change signal handler for SIGUSR1");
-        }
 
-        // Ignore SIGPIPE completely.
-        // INFO: If we add signals here we have to unblock them
-        // at popen.c when running a external plugin.
-        sigemptyset(&sa.sa_mask);
-        sigaddset(&sa.sa_mask, SIGPIPE);
-        sa.sa_handler = SIG_IGN;
-        if(sigaction(SIGPIPE, &sa, NULL) == -1) {
-            error("Failed to change signal handler for SIGPIPE");
-        }
+        // reload health configuration on SIGUSR2
+        sa.sa_handler = sig_handler_reload_health;
+        if(sigaction(SIGUSR2, &sa, NULL) == -1)
+            error("Failed to change signal handler for SIGUSR2");
 
         // --------------------------------------------------------------------