Skip to content

Commit

Permalink
campaignd: Implement 'flush' command, flushes config to disk immediately
Browse files Browse the repository at this point in the history
  • Loading branch information
irydacea committed Apr 24, 2015
1 parent 44eef2a commit b512a7c
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/campaign_server/campaign_server.cpp
Expand Up @@ -285,6 +285,7 @@ void server::run()
}

try {
bool force_flush = false;
std::string admin_cmd;

if(input_ && input_->read_line(admin_cmd)) {
Expand All @@ -299,14 +300,17 @@ void server::run()
}

LOG_CS << "Read only mode: " << (read_only_ ? "enabled" : "disabled") << '\n';
} else if(ctl == "flush") {
force_flush = true;
LOG_CS << "Flushing config to disk...\n";
} else {
LOG_CS << "Unrecognized admin command: " << ctl.full() << '\n';
}
}

const time_t cur_ts = monotonic_clock();
// Write config to disk every ten minutes.
if(labs(cur_ts - last_ts) >= 10*60) {
if(force_flush || labs(cur_ts - last_ts) >= 10*60) {
write_config();
last_ts = cur_ts;
}
Expand Down

0 comments on commit b512a7c

Please sign in to comment.