]> git.sesse.net Git - cubemap/blobdiff - main.cpp
Fix HTTP connections to IPv6 address literals.
[cubemap] / main.cpp
index ef75277eb5899285b0fe994b07c0c03f6da030b1..1b6fb4f8103db87287646f258546e045e11dba5c 100644 (file)
--- a/main.cpp
+++ b/main.cpp
@@ -9,6 +9,7 @@
 #include <string.h>
 #include <sys/time.h>
 #include <sys/wait.h>
+#include <systemd/sd-daemon.h>
 #include <unistd.h>
 #include <algorithm>
 #include <map>
@@ -230,6 +231,12 @@ void create_streams(const Config &config,
                        ++input_it->second.refcount;
                }
        }
+
+       // HTTP gen204 endpoints.
+       for (unsigned i = 0; i < config.pings.size(); ++i) {
+               const Gen204Config &ping_config = config.pings[i];
+               servers->add_gen204(ping_config.url, ping_config.allow_origin);
+       }
 }
        
 void open_logs(const vector<LogConfig> &log_destinations)
@@ -248,7 +255,7 @@ void open_logs(const vector<LogConfig> &log_destinations)
        start_logging();
 }
        
-bool dry_run_config(const std::string &argv0, const std::string &config_filename)
+bool dry_run_config(const string &argv0, const string &config_filename)
 {
        char *argv0_copy = strdup(argv0.c_str());
        char *config_filename_copy = strdup(config_filename.c_str());
@@ -541,10 +548,18 @@ start:
                log(INFO, "Re-exec happened in approx. %.0f ms.", glitch_time * 1000.0);
        }
 
+       sd_notify(0, "READY=1");
+
        while (!hupped) {
                usleep(100000);
        }
 
+       if (stopped) {
+               sd_notify(0, "STOPPING=1");
+       } else {
+               sd_notify(0, "RELOADING=1");
+       }
+
        // OK, we've been HUPed. Time to shut down everything, serialize, and re-exec.
        err = clock_gettime(CLOCK_MONOTONIC, &serialize_start);
        assert(err != -1);