hydra-queue-runner: Ensure regular status dumps

This commit is contained in:
Eelco Dolstra 2016-03-09 17:11:34 +01:00
parent 4151be7e69
commit 4b9c76e502
2 changed files with 9 additions and 3 deletions

View file

@ -683,7 +683,10 @@ void State::dumpStatus(Connection & conn, bool log)
}
}
if (log) printMsg(lvlInfo, format("status: %1%") % out.str());
if (log && time(0) >= lastStatusLogged + statusLogInterval) {
printMsg(lvlInfo, format("status: %1%") % out.str());
lastStatusLogged = time(0);
}
{
auto mc = startDbUpdate();
@ -826,8 +829,8 @@ void State::run(BuildID buildOne)
auto conn(dbPool.get());
receiver dumpStatus_(*conn, "dump_status");
while (true) {
bool timeout = conn->await_notification(300, 0) == 0;
dumpStatus(*conn, timeout);
conn->await_notification(statusLogInterval / 2 + 1, 0);
dumpStatus(*conn, true);
}
} catch (std::exception & e) {
printMsg(lvlError, format("main thread: %1%") % e.what());

View file

@ -359,6 +359,9 @@ private:
size_t maxOutputSize = 2ULL << 30;
time_t lastStatusLogged = 0;
const int statusLogInterval = 20;
public:
State();