Concurrent hydra-evaluator
This rewrites the top-level loop of hydra-evaluator in C++. The Perl stuff is moved into hydra-eval-jobset. (Rewriting the entire evaluator would be nice but is a bit too much work.) The new version has some advantages: * It can run multiple jobset evaluations in parallel. * It uses PostgreSQL notifications so it doesn't have to poll the database. So if a jobset is triggered via the web interface or from a GitHub / Bitbucket webhook, evaluation of the jobset will start almost instantaneously (assuming the evaluator is not at its concurrency limit). * It imposes a timeout on evaluations. So if e.g. hydra-eval-jobset hangs connecting to a Mercurial server, it will eventually be killed.
This commit is contained in:
@ -4,5 +4,4 @@ hydra_queue_runner_SOURCES = hydra-queue-runner.cc queue-monitor.cc dispatcher.c
|
||||
builder.cc build-result.cc build-remote.cc \
|
||||
build-result.hh counter.hh token-server.hh state.hh db.hh
|
||||
hydra_queue_runner_LDADD = $(NIX_LIBS) -lpqxx
|
||||
|
||||
AM_CXXFLAGS = $(NIX_CFLAGS) -Wall
|
||||
hydra_queue_runner_CXXFLAGS = $(NIX_CFLAGS) -Wall -I ../libhydra
|
||||
|
@ -1,38 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <pqxx/pqxx>
|
||||
|
||||
#include "util.hh"
|
||||
|
||||
|
||||
struct Connection : pqxx::connection
|
||||
{
|
||||
Connection() : pqxx::connection(getFlags()) { };
|
||||
|
||||
std::string getFlags()
|
||||
{
|
||||
using namespace nix;
|
||||
auto s = getEnv("HYDRA_DBI", "dbi:Pg:dbname=hydra;");
|
||||
std::string prefix = "dbi:Pg:";
|
||||
if (std::string(s, 0, prefix.size()) != prefix)
|
||||
throw Error("$HYDRA_DBI does not denote a PostgreSQL database");
|
||||
return concatStringsSep(" ", tokenizeString<Strings>(string(s, prefix.size()), ";"));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
struct receiver : public pqxx::notification_receiver
|
||||
{
|
||||
bool status = false;
|
||||
receiver(pqxx::connection_base & c, const std::string & channel)
|
||||
: pqxx::notification_receiver(c, channel) { }
|
||||
void operator() (const std::string & payload, int pid) override
|
||||
{
|
||||
status = true;
|
||||
};
|
||||
bool get() {
|
||||
bool b = status;
|
||||
status = false;
|
||||
return b;
|
||||
}
|
||||
};
|
Reference in New Issue
Block a user