initialize in the right sequence
Costa Tsaousis (ktsaou) committed
Feb 25, 2017 at 00:02 UTC
f348a45651c12e52e3eb97346b955a6a9a3f624c
2 files changed
+8
-36
src/main.c
+3
-35
@@ -225,7 +225,6 @@ struct option_def options[] = {
225
{ 'h', "Display this help message.", NULL, NULL},
226
{ 'P', "File to save a pid while running.", "filename", "do not save pid to a file"},
227
{ 'i', "The IP address to listen to.", "IP", "all IP addresses IPv4 and IPv6"},
228
- { 'k', "Check health configuration and exit.", NULL, NULL},
228
{ 'p', "API/Web port to use.", "port", "19999"},
229
{ 's', "Prefix for /proc and /sys (for containers).", "path", "no prefix"},
230
{ 't', "The internal clock of netdata.", "seconds", "1"},
@@ -517,7 +516,7 @@ void set_global_environment() {
516
}
517
518
int main(int argc, char **argv) {
520
- int i, check_config = 0;
519
+ int i;
520
int config_loaded = 0;
521
int dont_fork = 0;
522
size_t wanted_stacksize = 0, stacksize = 0;
@@ -595,10 +594,6 @@ int main(int argc, char **argv) {
594
case 'i':
595
config_set(CONFIG_SECTION_API, "bind to", optarg);
596
break;
598
- case 'k':
599
- dont_fork = 1;
600
- check_config = 1;
601
- break;
597
case 'P':
598
strncpy(pidfile, optarg, FILENAME_MAX);
599
pidfile[FILENAME_MAX] = '\0';
@@ -756,11 +751,6 @@ int main(int argc, char **argv) {
751
// get log filenames and settings
752
753
log_init();
759
- if(check_config) {
760
- stdout_filename = stderr_filename = stdaccess_filename = "system";
761
- error_log_throttle_period = 0;
762
- error_log_errors_per_period = 0;
763
- }
754
error_log_limit_unlimited();
755
756
// --------------------------------------------------------------------
@@ -855,7 +845,7 @@ int main(int argc, char **argv) {
845
// --------------------------------------------------------------------
846
// create the listening sockets
847
858
- if(!check_config && web_server_mode != WEB_SERVER_MODE_NONE)
848
+ if(web_server_mode != WEB_SERVER_MODE_NONE)
849
create_listen_sockets();
850
851
@@ -903,33 +893,11 @@ int main(int argc, char **argv) {
893
894
895
// ------------------------------------------------------------------------
906
- // initialize rrd host
896
+ // initialize rrd, registry, health, rrdpush, etc.
897
898
rrd_init(netdata_configured_hostname);
899
900
911
- // --------------------------------------------------------------------
912
- // find we need to send data to another netdata
913
-
914
- rrdpush_init();
915
-
916
-
917
- // ------------------------------------------------------------------------
918
- // initialize health monitoring
919
-
920
- health_init();
921
-
922
-
923
- // ------------------------------------------------------------------------
924
- // initialize the registry
925
-
926
- registry_init();
927
-
928
-
929
- if(check_config)
930
- exit(1);
931
-
932
-
901
// ------------------------------------------------------------------------
902
// enable log flood protection
903
src/rrdhost.c
+5
-1
@@ -230,8 +230,10 @@ RRDHOST *rrdhost_find_or_create(const char *hostname, const char *guid, const ch
230
// RRDHOST global / startup initialization
231
232
void rrd_init(char *hostname) {
233
- debug(D_RRDHOST, "Initializing localhost with hostname '%s'", hostname);
233
+ health_init();
234
+ registry_init();
235
236
+ debug(D_RRDHOST, "Initializing localhost with hostname '%s'", hostname);
237
localhost = rrdhost_create(hostname,
238
registry_get_this_machine_guid(),
239
os_type,
@@ -241,6 +243,8 @@ void rrd_init(char *hostname) {
243
default_health_enabled,
244
1
245
);
246
+
247
+ rrdpush_init();
248
}
249
250
// ----------------------------------------------------------------------------