implement LAMINAR_KEEP_WORKDIR

pull/5/head
Oliver Giles 9 years ago
parent 291428ef2d
commit ae59da1245

@ -6,4 +6,12 @@
### ###
### Default: /var/lib/laminar ### 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

@ -62,6 +62,7 @@ constexpr const char* BASE_CFG_DIR = "/home/og/dev/laminar/cfg";
typedef std::string str; typedef std::string str;
Laminar::Laminar() { Laminar::Laminar() {
eraseWorkdir = true;
homeDir = getenv("LAMINAR_HOME") ?: "/var/lib/laminar"; homeDir = getenv("LAMINAR_HOME") ?: "/var/lib/laminar";
db = new Database((fs::path(homeDir)/"laminar.sqlite").string().c_str()); db = new Database((fs::path(homeDir)/"laminar.sqlite").string().c_str());
@ -269,6 +270,9 @@ void Laminar::stop() {
} }
bool Laminar::loadConfiguration() { bool Laminar::loadConfiguration() {
if(getenv("LAMINAR_KEEP_WORKDIR"))
eraseWorkdir = false;
NodeMap nm; NodeMap nm;
fs::path nodeCfg = fs::path(homeDir)/"cfg"/"nodes"; fs::path nodeCfg = fs::path(homeDir)/"cfg"/"nodes";
@ -492,7 +496,7 @@ void Laminar::assignNewJobs() {
} }
// setup run completion handler // setup run completion handler
run->notifyCompletion = [&](const Run* r) { run->notifyCompletion = [=,&node](const Run* r) {
node.busyExecutors--; node.busyExecutors--;
KJ_LOG(INFO, "Run completed", r->name, to_string(r->result)); KJ_LOG(INFO, "Run completed", r->name, to_string(r->result));
time_t completedAt = time(0); time_t completedAt = time(0);
@ -522,6 +526,9 @@ void Laminar::assignNewJobs() {
waiter.release(r->result); waiter.release(r->result);
waiters.erase(r); waiters.erase(r);
// remove the workdir
fs::remove_all(wd);
// will delete the job // will delete the job
activeJobs.get<2>().erase(r); activeJobs.get<2>().erase(r);
}; };

@ -83,6 +83,7 @@ private:
NodeMap nodes; NodeMap nodes;
std::string homeDir; std::string homeDir;
std::set<LaminarClient*> clients; std::set<LaminarClient*> clients;
bool eraseWorkdir;
}; };
#endif // _LAMINAR_LAMINAR_H_ #endif // _LAMINAR_LAMINAR_H_

Loading…
Cancel
Save