1
0
mirror of https://github.com/ohwgiles/laminar.git synced 2026-10-17 16:43:26 +00:00

fix LAST_RESULT env var

the variable was set too late to be passed to the forked
process.

resolves #131
This commit is contained in:
Oliver Giles
2020-09-20 09:10:28 +12:00
parent 4b62e6dbf3
commit 6d2c0b208b
3 changed files with 9 additions and 8 deletions

View File

@@ -618,16 +618,19 @@ bool Laminar::tryStartRun(std::shared_ptr<Run> run, int queueIndex) {
std::shared_ptr<Context> ctx = sc.second;
if(ctx->canQueue(jobContexts.at(run->name))) {
kj::Promise<RunState> onRunFinished = run->start(buildNums[run->name] + 1, ctx, *fsHome,[this](kj::Maybe<pid_t>& pid){return srv.onChildExit(pid);});
RunState lastResult = RunState::UNKNOWN;
ctx->busyExecutors++;
// set the last known result if exists
db->stmt("SELECT result FROM builds WHERE name = ? ORDER BY completedAt DESC LIMIT 1")
.bind(run->name)
.fetch<int>([=](int result){
run->lastResult = RunState(result);
.fetch<int>([&](int result){
lastResult = RunState(result);
});
kj::Promise<RunState> onRunFinished = run->start(buildNums[run->name] + 1, lastResult, ctx, *fsHome,[this](kj::Maybe<pid_t>& pid){return srv.onChildExit(pid);});
ctx->busyExecutors++;
kj::Promise<void> exec = srv.readDescriptor(run->output_fd, [this, run](const char*b, size_t n){
// handle log output
std::string s(b, n);