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AC D5QIOJGPKQJIYBUCSC3MFJ3TXLPNZ2XMI37GXMFRVRFWWR2VMTFAC State::~State(){try {printMsg(lvlInfo, "clearing active builds / build steps...");clearBusy(time(0));} catch (...) {ignoreException();}}
auto builds_(builds.lock());printMsg(lvlError, format("%1% queued builds") % builds_->size());
JSONObject root(out);root.attr("status", "up");root.attr("time", time(0));root.attr("pid", getpid());{auto builds_(builds.lock());root.attr("nrQueuedBuilds", builds_->size());}{auto steps_(steps.lock());for (auto i = steps_->begin(); i != steps_->end(); )if (i->second.lock()) ++i; else i = steps_->erase(i);root.attr("nrUnfinishedSteps", steps_->size());}{auto runnable_(runnable.lock());for (auto i = runnable_->begin(); i != runnable_->end(); )if (i->lock()) ++i; else i = runnable_->erase(i);root.attr("nrRunnableSteps", runnable_->size());}root.attr("nrActiveSteps", nrActiveSteps);root.attr("nrStepsBuilding", nrStepsBuilding);root.attr("nrBuildsRead", nrBuildsRead);root.attr("nrBuildsDone", nrBuildsDone);root.attr("nrStepsDone", nrStepsDone);root.attr("nrRetries", nrRetries);root.attr("maxNrRetries", maxNrRetries);root.attr("nrQueueWakeups", nrQueueWakeups);root.attr("nrDispatcherWakeups", nrDispatcherWakeups);root.attr("nrDbConnections", dbPool.count());{root.attr("machines");JSONObject nested(out);auto machines_(machines.lock());for (auto & m : *machines_) {nested.attr(m->sshName);JSONObject nested2(out);nested2.attr("currentJobs", m->currentJobs);nested2.attr("maxJobs", m->maxJobs);}}
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());
pqxx::work txn(conn);// FIXME: use PostgreSQL 9.5 upsert.txn.exec("delete from SystemStatus where what = 'queue-runner'");txn.parameterized("insert into SystemStatus values ('queue-runner', $1)")(out.str()).exec();txn.exec("notify status_dumped");txn.commit();
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());
pqxx::work txn(*conn);auto res = txn.exec("select status from SystemStatus where what = 'queue-runner'");if (res.size()) status = res[0][0].as<string>();}if (status != "") {/* If the status is not empty, then the queue runner isrunning. Ask it to update the status dump. */{pqxx::work txn(*conn);txn.exec("notify dump_status");txn.commit();}/* Wait until it has done so. */barf = conn->await_notification(5, 0) == 0;/* Get the new status. */{pqxx::work txn(*conn);auto res = txn.exec("select status from SystemStatus where what = 'queue-runner'");if (res.size()) status = res[0][0].as<string>();}
printMsg(lvlError, format("%1% active build steps") % nrActiveSteps);printMsg(lvlError, format("%1% build steps currently building") % nrStepsBuilding);printMsg(lvlError, format("%1% builds read from queue") % nrBuildsRead);printMsg(lvlError, format("%1% builds done") % nrBuildsDone);printMsg(lvlError, format("%1% build steps done") % nrStepsDone);printMsg(lvlError, format("%1% build step retries") % nrRetries);printMsg(lvlError, format("%1% most retries for any build step") % maxNrRetries);printMsg(lvlError, format("%1% queue wakeups") % nrQueueWakeups);printMsg(lvlError, format("%1% dispatcher wakeups") % nrDispatcherWakeups);printMsg(lvlError, format("%1% database connections") % dbPool.count());
if (status == "") status = R"({"status":"down"})";std::cout << status << "\n";if (barf)throw Error("queue runner did not respond; status information may be wrong");}void State::unlock(){auto conn(dbPool.get());clearBusy(*conn, 0);
auto machines_(machines.lock());for (auto & m : *machines_) {printMsg(lvlError, format("machine %1%: %2%/%3% active")% m->sshName % m->currentJobs % m->maxJobs);}
pqxx::work txn(*conn);txn.exec("delete from SystemStatus where what = 'queue-runner'");txn.commit();
create table SystemStatus (what text primary key not null,status json not null);