diff --git a/laminar.conf b/laminar.conf index aeb6a06..8093558 100644 --- a/laminar.conf +++ b/laminar.conf @@ -6,4 +6,12 @@ ### ### Default: /var/lib/laminar ### -LAMINAR_HOME=/var/lib/laminar +#LAMINAR_HOME=/var/lib/laminar + +### +### LAMINAR_KEEP_WORKDIR +### +### If set (to anything), the job workdir $LAMINAR_HOME/run/$JOB/$NUM +### will not be deleted after the run has completed +### +#LAMINAR_KEEP_WORKDIR=1 diff --git a/src/laminar.cpp b/src/laminar.cpp index d22f17b..5a170b6 100644 --- a/src/laminar.cpp +++ b/src/laminar.cpp @@ -62,6 +62,7 @@ constexpr const char* BASE_CFG_DIR = "/home/og/dev/laminar/cfg"; typedef std::string str; Laminar::Laminar() { + eraseWorkdir = true; homeDir = getenv("LAMINAR_HOME") ?: "/var/lib/laminar"; db = new Database((fs::path(homeDir)/"laminar.sqlite").string().c_str()); @@ -269,6 +270,9 @@ void Laminar::stop() { } bool Laminar::loadConfiguration() { + if(getenv("LAMINAR_KEEP_WORKDIR")) + eraseWorkdir = false; + NodeMap nm; fs::path nodeCfg = fs::path(homeDir)/"cfg"/"nodes"; @@ -492,7 +496,7 @@ void Laminar::assignNewJobs() { } // setup run completion handler - run->notifyCompletion = [&](const Run* r) { + run->notifyCompletion = [=,&node](const Run* r) { node.busyExecutors--; KJ_LOG(INFO, "Run completed", r->name, to_string(r->result)); time_t completedAt = time(0); @@ -522,6 +526,9 @@ void Laminar::assignNewJobs() { waiter.release(r->result); waiters.erase(r); + // remove the workdir + fs::remove_all(wd); + // will delete the job activeJobs.get<2>().erase(r); }; diff --git a/src/laminar.h b/src/laminar.h index 28dc9fa..e585899 100644 --- a/src/laminar.h +++ b/src/laminar.h @@ -83,6 +83,7 @@ private: NodeMap nodes; std::string homeDir; std::set clients; + bool eraseWorkdir; }; #endif // _LAMINAR_LAMINAR_H_