mirror of
https://github.com/ohwgiles/laminar.git
synced 2024-10-27 20:34:20 +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:
parent
4b62e6dbf3
commit
6d2c0b208b
@ -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);
|
||||
|
@ -46,7 +46,6 @@ std::string to_string(const RunState& rs) {
|
||||
|
||||
Run::Run(std::string name, ParamMap pm, kj::Path&& rootPath) :
|
||||
result(RunState::SUCCESS),
|
||||
lastResult(RunState::UNKNOWN),
|
||||
name(name),
|
||||
params(kj::mv(pm)),
|
||||
queuedAt(time(nullptr)),
|
||||
@ -84,7 +83,7 @@ static void setEnvFromFile(const kj::Path& rootPath, kj::Path file) {
|
||||
}
|
||||
}
|
||||
|
||||
kj::Promise<RunState> Run::start(uint buildNum, std::shared_ptr<Context> ctx, const kj::Directory &fsHome, std::function<kj::Promise<int>(kj::Maybe<pid_t>&)> getPromise)
|
||||
kj::Promise<RunState> Run::start(uint buildNum, RunState lastResult, std::shared_ptr<Context> ctx, const kj::Directory &fsHome, std::function<kj::Promise<int>(kj::Maybe<pid_t>&)> getPromise)
|
||||
{
|
||||
kj::Path cfgDir{"cfg"};
|
||||
|
||||
|
@ -57,7 +57,7 @@ public:
|
||||
Run(const Run&) = delete;
|
||||
Run& operator=(const Run&) = delete;
|
||||
|
||||
kj::Promise<RunState> start(uint buildNum, std::shared_ptr<Context> ctx, const kj::Directory &fsHome, std::function<kj::Promise<int>(kj::Maybe<pid_t>&)> getPromise);
|
||||
kj::Promise<RunState> start(uint buildNum, RunState lastResult, std::shared_ptr<Context> ctx, const kj::Directory &fsHome, std::function<kj::Promise<int>(kj::Maybe<pid_t>&)> getPromise);
|
||||
|
||||
// aborts this run
|
||||
bool abort();
|
||||
@ -69,7 +69,6 @@ public:
|
||||
|
||||
std::shared_ptr<Context> context;
|
||||
RunState result;
|
||||
RunState lastResult;
|
||||
std::string name;
|
||||
std::string parentName;
|
||||
int parentBuild = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user