]> git.sesse.net Git - cubemap/blobdiff - main.cpp
Add preliminary support for input stream statistics.
[cubemap] / main.cpp
index 8d60826fb3d7a8436607446f27b572ba294bc237..c40b78f5ef3ba20bea62cc86589903cd69aa9c0e 100644 (file)
--- a/main.cpp
+++ b/main.cpp
@@ -20,6 +20,7 @@
 #include "accesslog.h"
 #include "config.h"
 #include "input.h"
+#include "input_stats.h"
 #include "log.h"
 #include "markpool.h"
 #include "serverpool.h"
@@ -448,6 +449,18 @@ start:
                stats_thread->run();
        }
 
+       InputStatsThread *input_stats_thread = NULL;
+       if (!config.input_stats_file.empty()) {
+               vector<Input*> inputs_no_refcount;
+               for (multimap<string, InputWithRefcount>::iterator input_it = inputs.begin();
+                    input_it != inputs.end(); ++input_it) {
+                       inputs_no_refcount.push_back(input_it->second.input);
+               }
+
+               input_stats_thread = new InputStatsThread(config.input_stats_file, config.input_stats_interval, inputs_no_refcount);
+               input_stats_thread->run();
+       }
+
        struct timeval server_start;
        gettimeofday(&server_start, NULL);
        if (state_fd != -1) {
@@ -466,6 +479,10 @@ start:
        // OK, we've been HUPed. Time to shut down everything, serialize, and re-exec.
        gettimeofday(&serialize_start, NULL);
 
+       if (input_stats_thread != NULL) {
+               input_stats_thread->stop();
+               delete input_stats_thread;
+       }
        if (stats_thread != NULL) {
                stats_thread->stop();
                delete stats_thread;