]> arthur.barton.de Git - netdata.git/blobdiff - src/registry_init.c
allow each netdata host to have its own thread for streaming metrics
[netdata.git] / src / registry_init.c
index f2027b89c659fe176d1b6e8319c6aa3c22acbbc6..2d8eb5709ee47817af0ffa173f67f7fbad2c367f 100644 (file)
@@ -4,17 +4,24 @@ int registry_init(void) {
     char filename[FILENAME_MAX + 1];
 
     // registry enabled?
-    registry.enabled = config_get_boolean("registry", "enabled", 0);
+    if(!default_rrdpush_exclusive) {
+        registry.enabled = config_get_boolean("registry", "enabled", 0);
+    }
+    else {
+        info("Registry is disabled - use the central netdata");
+        config_set_boolean("registry", "enabled", 0);
+        registry.enabled = 0;
+    }
 
     // pathnames
-    registry.pathname = config_get("registry", "registry db directory", VARLIB_DIR "/registry");
+    snprintfz(filename, FILENAME_MAX, "%s/registry", netdata_configured_varlib_dir);
+    registry.pathname = config_get("registry", "registry db directory", filename);
     if(mkdir(registry.pathname, 0770) == -1 && errno != EEXIST)
         fatal("Cannot create directory '%s'.", registry.pathname);
 
     // filenames
     snprintfz(filename, FILENAME_MAX, "%s/netdata.public.unique.id", registry.pathname);
     registry.machine_guid_filename = config_get("registry", "netdata unique id file", filename);
-    registry_get_this_machine_guid();
 
     snprintfz(filename, FILENAME_MAX, "%s/registry.db", registry.pathname);
     registry.db_filename = config_get("registry", "registry db file", filename);
@@ -27,7 +34,7 @@ int registry_init(void) {
     registry.persons_expiration = config_get_number("registry", "registry expire idle persons days", 365) * 86400;
     registry.registry_domain = config_get("registry", "registry domain", "");
     registry.registry_to_announce = config_get("registry", "registry to announce", "https://registry.my-netdata.io");
-    registry.hostname = config_get("registry", "registry hostname", config_get("global", "hostname", localhost.hostname));
+    registry.hostname = config_get("registry", "registry hostname", config_get("global", "hostname", "localhost"));
     registry.verify_cookies_redirects = config_get_boolean("registry", "verify browser cookies support", 1);
 
     setenv("NETDATA_REGISTRY_HOSTNAME", registry.hostname, 1);
@@ -89,32 +96,7 @@ void registry_free(void) {
 
     while(registry.persons->values_index.root) {
         REGISTRY_PERSON *p = ((NAME_VALUE *)registry.persons->values_index.root)->value;
-
-        // fprintf(stderr, "\nPERSON: '%s', first: %u, last: %u, usages: %u\n", p->guid, p->first_t, p->last_t, p->usages);
-
-        while(p->person_urls->values_index.root) {
-            REGISTRY_PERSON_URL *pu = ((NAME_VALUE *)p->person_urls->values_index.root)->value;
-
-            // fprintf(stderr, "\tURL: '%s', first: %u, last: %u, usages: %u, flags: 0x%02x\n", pu->url->url, pu->first_t, pu->last_t, pu->usages, pu->flags);
-
-            debug(D_REGISTRY, "Registry: deleting url '%s' from person '%s'", pu->url->url, p->guid);
-            dictionary_del(p->person_urls, pu->url->url);
-
-            debug(D_REGISTRY, "Registry: unlinking url '%s' from person", pu->url->url);
-            registry_url_unlink(pu->url);
-
-            debug(D_REGISTRY, "Registry: freeing person url");
-            freez(pu);
-        }
-
-        debug(D_REGISTRY, "Registry: deleting person '%s' from persons registry", p->guid);
-        dictionary_del(registry.persons, p->guid);
-
-        debug(D_REGISTRY, "Registry: destroying URL dictionary of person '%s'", p->guid);
-        dictionary_destroy(p->person_urls);
-
-        debug(D_REGISTRY, "Registry: freeing person '%s'", p->guid);
-        freez(p);
+        registry_person_del(p);
     }
 
     while(registry.machines->values_index.root) {
@@ -158,3 +140,4 @@ void registry_free(void) {
     debug(D_REGISTRY, "Registry: destroying machines dictionary");
     dictionary_destroy(registry.machines);
 }
+