forked from lix-project/hydra
Add status dump facility
Doing $ psql hydra -c 'notify dump_status' will cause hydra-queue-runner to dump some internal status info on stderr.
This commit is contained in:
parent
dd104f14ea
commit
42e7301c08
|
@ -202,6 +202,10 @@ private:
|
||||||
worth it. */
|
worth it. */
|
||||||
// std::vector<std::thread> builderThreads;
|
// std::vector<std::thread> builderThreads;
|
||||||
|
|
||||||
|
|
||||||
|
/* Various stats. */
|
||||||
|
std::atomic<int> nrQueueWakeups;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
State();
|
State();
|
||||||
|
|
||||||
|
@ -256,12 +260,16 @@ public:
|
||||||
|
|
||||||
bool checkCachedFailure(Step::ptr step, Connection & conn);
|
bool checkCachedFailure(Step::ptr step, Connection & conn);
|
||||||
|
|
||||||
|
void dumpStatus();
|
||||||
|
|
||||||
void run();
|
void run();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
State::State()
|
State::State()
|
||||||
{
|
{
|
||||||
|
nrQueueWakeups = 0;
|
||||||
|
|
||||||
hydraData = getEnv("HYDRA_DATA");
|
hydraData = getEnv("HYDRA_DATA");
|
||||||
if (hydraData == "") throw Error("$HYDRA_DATA must be set");
|
if (hydraData == "") throw Error("$HYDRA_DATA must be set");
|
||||||
|
|
||||||
|
@ -419,6 +427,7 @@ void State::queueMonitorLoop()
|
||||||
receiver buildsAdded(*conn, "builds_added");
|
receiver buildsAdded(*conn, "builds_added");
|
||||||
receiver buildsRestarted(*conn, "builds_restarted");
|
receiver buildsRestarted(*conn, "builds_restarted");
|
||||||
receiver buildsCancelled(*conn, "builds_cancelled");
|
receiver buildsCancelled(*conn, "builds_cancelled");
|
||||||
|
receiver dumpStatus(*conn, "dump_status");
|
||||||
|
|
||||||
auto store = openStore(); // FIXME: pool
|
auto store = openStore(); // FIXME: pool
|
||||||
|
|
||||||
|
@ -430,6 +439,7 @@ void State::queueMonitorLoop()
|
||||||
/* Sleep until we get notification from the database about an
|
/* Sleep until we get notification from the database about an
|
||||||
event. */
|
event. */
|
||||||
conn->await_notification();
|
conn->await_notification();
|
||||||
|
nrQueueWakeups++;
|
||||||
|
|
||||||
if (buildsAdded.get())
|
if (buildsAdded.get())
|
||||||
printMsg(lvlTalkative, "got notification: new builds added to the queue");
|
printMsg(lvlTalkative, "got notification: new builds added to the queue");
|
||||||
|
@ -441,6 +451,9 @@ void State::queueMonitorLoop()
|
||||||
printMsg(lvlTalkative, "got notification: builds cancelled");
|
printMsg(lvlTalkative, "got notification: builds cancelled");
|
||||||
removeCancelledBuilds(*conn);
|
removeCancelledBuilds(*conn);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (dumpStatus.get())
|
||||||
|
State::dumpStatus();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1095,6 +1108,36 @@ bool State::checkCachedFailure(Step::ptr step, Connection & conn)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void State::dumpStatus()
|
||||||
|
{
|
||||||
|
{
|
||||||
|
auto builds_(builds.lock());
|
||||||
|
printMsg(lvlError, format("%1% queued builds") % builds_->size());
|
||||||
|
}
|
||||||
|
{
|
||||||
|
auto steps_(steps.lock());
|
||||||
|
for (auto i = steps_->begin(); i != steps_->end(); )
|
||||||
|
if (i->second.lock()) ++i; else i = steps_->erase(i);
|
||||||
|
printMsg(lvlError, format("%1% pending/active build steps") % steps_->size());
|
||||||
|
}
|
||||||
|
{
|
||||||
|
auto runnable_(runnable.lock());
|
||||||
|
for (auto i = runnable_->begin(); i != runnable_->end(); )
|
||||||
|
if (i->lock()) ++i; else i = runnable_->erase(i);
|
||||||
|
printMsg(lvlError, format("%1% runnable build steps") % runnable_->size());
|
||||||
|
}
|
||||||
|
printMsg(lvlError, format("%1% times woken up to check the queue") % nrQueueWakeups);
|
||||||
|
{
|
||||||
|
auto machines_(machines.lock());
|
||||||
|
for (auto & m : *machines_) {
|
||||||
|
auto currentJobs_(m->currentJobs.lock());
|
||||||
|
printMsg(lvlError, format("machine %1%: %2%/%3% active")
|
||||||
|
% m->sshName % *currentJobs_ % m->maxJobs);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void State::run()
|
void State::run()
|
||||||
{
|
{
|
||||||
clearBusy(0);
|
clearBusy(0);
|
||||||
|
@ -1117,6 +1160,10 @@ int main(int argc, char * * argv)
|
||||||
return handleExceptions(argv[0], [&]() {
|
return handleExceptions(argv[0], [&]() {
|
||||||
initNix();
|
initNix();
|
||||||
|
|
||||||
|
parseCmdLine(argc, argv, [&](Strings::iterator & arg, const Strings::iterator & end) {
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
signal(SIGINT, SIG_DFL);
|
signal(SIGINT, SIG_DFL);
|
||||||
signal(SIGTERM, SIG_DFL);
|
signal(SIGTERM, SIG_DFL);
|
||||||
signal(SIGHUP, SIG_DFL);
|
signal(SIGHUP, SIG_DFL);
|
||||||
|
|
Loading…
Reference in a new issue