#include <utility>
#include <vector>
+#include "accesslog.h"
#include "acceptor.h"
#include "config.h"
#include "input.h"
using namespace std;
+AccessLogThread *access_log = NULL;
ServerPool *servers = NULL;
+vector<MarkPool *> mark_pools;
volatile bool hupped = false;
volatile bool stopped = false;
const set<string> &deserialized_stream_ids,
map<string, Input *> *deserialized_inputs)
{
- vector<MarkPool *> mark_pools; // FIXME: leak
for (unsigned i = 0; i < config.mark_pools.size(); ++i) {
const MarkPoolConfig &mp_config = config.mark_pools[i];
mark_pools.push_back(new MarkPool(mp_config.from, mp_config.to));
char config_filename_canon[PATH_MAX];
if (realpath(argv[0], argv0_canon) == NULL) {
- log_perror("realpath");
+ log_perror(argv[0]);
exit(1);
}
if (realpath(config_filename.c_str(), config_filename_canon) == NULL) {
- log_perror("realpath");
+ log_perror(config_filename.c_str());
exit(1);
}
open_logs(config.log_destinations);
log(INFO, "Cubemap " SERVER_VERSION " starting.");
+ if (config.access_log_file.empty()) {
+ // Create a dummy logger.
+ access_log = new AccessLogThread();
+ } else {
+ access_log = new AccessLogThread(config.access_log_file);
+ }
+ access_log->run();
+
servers = new ServerPool(config.num_servers);
CubemapStateProto loaded_state;
if (stats_thread != NULL) {
stats_thread->stop();
+ delete stats_thread;
}
for (size_t i = 0; i < acceptors.size(); ++i) {
acceptors[i]->stop();
}
}
delete servers;
+
+ for (unsigned i = 0; i < mark_pools.size(); ++i) {
+ delete mark_pools[i];
+ }
+ mark_pools.clear();
+
+ access_log->stop();
+ delete access_log;
shut_down_logging();
if (stopped) {
}
// OK, so the signal was SIGHUP. Check that the new config is okay, then exec the new binary.
- if (!dry_run_config(argv[0], config_filename)) {
+ if (!dry_run_config(argv0_canon, config_filename_canon)) {
open_logs(config.log_destinations);
log(ERROR, "%s --test-config failed. Restarting old version instead of new.", argv[0]);
hupped = false;