mirror of
https://github.com/ohwgiles/laminar.git
synced 2026-11-03 00:54:44 +00:00
assign run numbers at queue time
This allows build chains to be traced in the common case where an upstream job calls `laminarc queue' instead of `laminarc start'. Incomplete job runs now have database entries, which requires some adjustments in queries. Queued jobs can now be viewed in the frontend and there is a corresponding status icon.
This commit is contained in:
12
src/run.cpp
12
src/run.cpp
@@ -33,7 +33,7 @@ inline kj::Path operator/(const kj::Path& p, const T& ext) {
|
||||
|
||||
std::string to_string(const RunState& rs) {
|
||||
switch(rs) {
|
||||
case RunState::PENDING: return "pending";
|
||||
case RunState::QUEUED: return "queued";
|
||||
case RunState::RUNNING: return "running";
|
||||
case RunState::ABORTED: return "aborted";
|
||||
case RunState::FAILED: return "failed";
|
||||
@@ -44,9 +44,10 @@ std::string to_string(const RunState& rs) {
|
||||
}
|
||||
|
||||
|
||||
Run::Run(std::string name, ParamMap pm, kj::Path&& rootPath) :
|
||||
Run::Run(std::string name, uint num, ParamMap pm, kj::Path&& rootPath) :
|
||||
result(RunState::SUCCESS),
|
||||
name(name),
|
||||
build(num),
|
||||
params(kj::mv(pm)),
|
||||
queuedAt(time(nullptr)),
|
||||
rootPath(kj::mv(rootPath)),
|
||||
@@ -83,7 +84,7 @@ static void setEnvFromFile(const kj::Path& rootPath, kj::Path file) {
|
||||
}
|
||||
}
|
||||
|
||||
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::Promise<RunState> Run::start(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"};
|
||||
|
||||
@@ -130,7 +131,7 @@ kj::Promise<RunState> Run::start(uint buildNum, RunState lastResult, std::shared
|
||||
PATH.append(p);
|
||||
}
|
||||
|
||||
std::string runNumStr = std::to_string(buildNum);
|
||||
std::string runNumStr = std::to_string(build);
|
||||
|
||||
setenv("PATH", PATH.c_str(), true);
|
||||
setenv("RUN", runNumStr.c_str(), true);
|
||||
@@ -151,14 +152,13 @@ kj::Promise<RunState> Run::start(uint buildNum, RunState lastResult, std::shared
|
||||
// enough. Instead, we'll just exec ourselves and handle that in laminard's
|
||||
// main() by calling leader_main()
|
||||
char* procName;
|
||||
if(asprintf(&procName, "{laminar} %s:%d", name.data(), buildNum) > 0)
|
||||
if(asprintf(&procName, "{laminar} %s:%d", name.data(), build) > 0)
|
||||
execl("/proc/self/exe", procName, NULL); // does not return
|
||||
_exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
// All good, we've "started"
|
||||
startedAt = time(nullptr);
|
||||
build = buildNum;
|
||||
context = ctx;
|
||||
|
||||
output_fd = plog[0];
|
||||
|
||||
Reference in New Issue
Block a user