From 4b9c76e5024d80bb8d4bf97644d6a4137d715557 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Wed, 9 Mar 2016 17:11:34 +0100 Subject: [PATCH] hydra-queue-runner: Ensure regular status dumps --- src/hydra-queue-runner/hydra-queue-runner.cc | 9 ++++++--- src/hydra-queue-runner/state.hh | 3 +++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/hydra-queue-runner/hydra-queue-runner.cc b/src/hydra-queue-runner/hydra-queue-runner.cc index c9377ab7..1c72af20 100644 --- a/src/hydra-queue-runner/hydra-queue-runner.cc +++ b/src/hydra-queue-runner/hydra-queue-runner.cc @@ -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()); diff --git a/src/hydra-queue-runner/state.hh b/src/hydra-queue-runner/state.hh index 048c91f4..465254c8 100644 --- a/src/hydra-queue-runner/state.hh +++ b/src/hydra-queue-runner/state.hh @@ -359,6 +359,9 @@ private: size_t maxOutputSize = 2ULL << 30; + time_t lastStatusLogged = 0; + const int statusLogInterval = 20; + public: State();