mirror of
				https://github.com/ohwgiles/laminar.git
				synced 2025-06-13 12:54:29 +00:00 
			
		
		
		
	add support for global, node and job level env files
This commit is contained in:
		
							parent
							
								
									1484f7a706
								
							
						
					
					
						commit
						291428ef2d
					
				| @ -460,6 +460,14 @@ void Laminar::assignNewJobs() { | ||||
|                 if(fs::exists(cfgDir/"after")) | ||||
|                     run->addScript((cfgDir/"after").string()); | ||||
| 
 | ||||
|                 // add environment files
 | ||||
|                 if(fs::exists(cfgDir/"env")) | ||||
|                     run->addEnv((cfgDir/"env").string()); | ||||
|                 if(fs::exists(cfgDir/"nodes"/node.name/"env")) | ||||
|                     run->addEnv((cfgDir/"nodes"/node.name/"env").string()); | ||||
|                 if(fs::exists(cfgDir/"jobs"/run->name/"env")) | ||||
|                     run->addEnv((cfgDir/"jobs"/run->name/"env").string()); | ||||
| 
 | ||||
|                 KJ_LOG(INFO, "Queued job to node", run->name, run->build, node.name); | ||||
| 
 | ||||
|                 // notify clients
 | ||||
|  | ||||
							
								
								
									
										15
									
								
								src/run.cpp
									
									
									
									
									
								
							
							
						
						
									
										15
									
								
								src/run.cpp
									
									
									
									
									
								
							| @ -17,7 +17,7 @@ | ||||
| /// along with Laminar.  If not, see <http://www.gnu.org/licenses/>
 | ||||
| ///
 | ||||
| #include "run.h" | ||||
| 
 | ||||
| #include "conf.h" | ||||
| #include <iostream> | ||||
| #include <kj/debug.h> | ||||
| 
 | ||||
| @ -26,7 +26,6 @@ | ||||
| #include <boost/filesystem.hpp> | ||||
| namespace fs = boost::filesystem; | ||||
| 
 | ||||
| 
 | ||||
| std::string to_string(const RunState& rs) { | ||||
|     switch(rs) { | ||||
|     case RunState::PENDING: return "pending"; | ||||
| @ -47,8 +46,8 @@ Run::Run() { | ||||
| 
 | ||||
| Run::~Run() { | ||||
|     KJ_DBG("Run destroyed"); | ||||
|     //delete log;
 | ||||
| } | ||||
| 
 | ||||
| std::string Run::reason() const { | ||||
|     if(!parentName.empty()) { | ||||
|         return std::string("Triggered by upstream ") + parentName + " #" + std::to_string(parentBuild); | ||||
| @ -81,6 +80,13 @@ bool Run::step() { | ||||
| 
 | ||||
|             chdir(wd.c_str()); | ||||
| 
 | ||||
|             for(std::string file : env) { | ||||
|                 StringMap vars = parseConfFile(file.c_str()); | ||||
|                 for(auto& it : vars) { | ||||
|                     setenv(it.first.c_str(), it.second.c_str(), true); | ||||
|                 } | ||||
|             } | ||||
| 
 | ||||
|             setenv("PATH", PATH.c_str(), true); | ||||
|             setenv("lBuildNum", buildNum.c_str(), true); | ||||
|             setenv("lJobName", name.c_str(), true); | ||||
| @ -110,6 +116,9 @@ bool Run::step() { | ||||
| void Run::addScript(std::string script) { | ||||
|     scripts.push(script); | ||||
| } | ||||
| void Run::addEnv(std::string path) { | ||||
|     env.push_back(path); | ||||
| } | ||||
| void Run::reaped(int status) { | ||||
|     procStatus = status; | ||||
| } | ||||
|  | ||||
| @ -21,6 +21,7 @@ | ||||
| 
 | ||||
| #include <string> | ||||
| #include <queue> | ||||
| #include <list> | ||||
| #include <functional> | ||||
| #include <ostream> | ||||
| #include <unordered_map> | ||||
| @ -57,6 +58,9 @@ public: | ||||
|     // adds a script to the queue of scripts to be executed by this run
 | ||||
|     void addScript(std::string script); | ||||
| 
 | ||||
|     // adds an environment file that will be sourced before this run
 | ||||
|     void addEnv(std::string path); | ||||
| 
 | ||||
|     // called when a process owned by this run has been reaped. The status
 | ||||
|     // may be used to set the run's job status
 | ||||
|     void reaped(int status); | ||||
| @ -85,6 +89,7 @@ public: | ||||
| private: | ||||
|     std::queue<std::string> scripts; | ||||
|     std::string currentScript; | ||||
|     std::list<std::string> env; | ||||
| }; | ||||
| 
 | ||||
| 
 | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user