Periodically dump/log status
This commit is contained in:
parent
4f4141e1db
commit
fbd7c02217
1 changed files with 7 additions and 6 deletions
|
@ -307,7 +307,7 @@ private:
|
||||||
/* Thread that asynchronously bzips logs of finished steps. */
|
/* Thread that asynchronously bzips logs of finished steps. */
|
||||||
void logCompressor();
|
void logCompressor();
|
||||||
|
|
||||||
void dumpStatus(Connection & conn);
|
void dumpStatus(Connection & conn, bool log);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
@ -1396,7 +1396,7 @@ void State::logCompressor()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void State::dumpStatus(Connection & conn)
|
void State::dumpStatus(Connection & conn, bool log)
|
||||||
{
|
{
|
||||||
std::ostringstream out;
|
std::ostringstream out;
|
||||||
|
|
||||||
|
@ -1444,6 +1444,8 @@ void State::dumpStatus(Connection & conn)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (log) printMsg(lvlInfo, format("status: %1%") % out.str());
|
||||||
|
|
||||||
{
|
{
|
||||||
pqxx::work txn(conn);
|
pqxx::work txn(conn);
|
||||||
// FIXME: use PostgreSQL 9.5 upsert.
|
// FIXME: use PostgreSQL 9.5 upsert.
|
||||||
|
@ -1520,7 +1522,7 @@ void State::run()
|
||||||
{
|
{
|
||||||
auto conn(dbPool.get());
|
auto conn(dbPool.get());
|
||||||
clearBusy(*conn, 0);
|
clearBusy(*conn, 0);
|
||||||
dumpStatus(*conn);
|
dumpStatus(*conn, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
loadMachines();
|
loadMachines();
|
||||||
|
@ -1538,9 +1540,8 @@ void State::run()
|
||||||
auto conn(dbPool.get());
|
auto conn(dbPool.get());
|
||||||
receiver dumpStatus(*conn, "dump_status");
|
receiver dumpStatus(*conn, "dump_status");
|
||||||
while (true) {
|
while (true) {
|
||||||
conn->await_notification();
|
bool timeout = conn->await_notification(300, 0) == 0;
|
||||||
if (dumpStatus.get())
|
State::dumpStatus(*conn, timeout);
|
||||||
State::dumpStatus(*conn);
|
|
||||||
}
|
}
|
||||||
} catch (std::exception & e) {
|
} catch (std::exception & e) {
|
||||||
printMsg(lvlError, format("main thread: %1%") % e.what());
|
printMsg(lvlError, format("main thread: %1%") % e.what());
|
||||||
|
|
Loading…
Reference in a new issue