Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // launch a job on a server against a target,
- // then monitor that job for completion (including the previous sub-job launch, if any)
- // once job is complete, make a new job (by calling make-job-for-target.script)
- partial = args[0]; // is this a partial sub-job? (needs to signal completion)
- server = args[1]; // run server
- target = args[2]; // target
- hackThreads = args[3]; //
- growThreads = args[4]; // work threads to launch
- weakThreads = args[5]; //
- monID = args[6]; // supplemental monitor ID (if there is a previous sub-job to monitor, or -1 if not)
- // append a unique ID in case another copy of this script is already running on this server
- function execUniq(script,server,threads,target) {
- uniqID = 0;
- while (isRunning(script,server,target,uniqID)) { ++uniqID; }
- exec(script,server,threads,target,uniqID);
- return uniqID;
- }
- script = null;
- uniqID = 0;
- if (hackThreads > 0) {
- script = 'hackloop.script';
- uniqID = execUniq(script,server,hackThreads,target);
- }
- if (growThreads > 0) {
- script = 'grow.script';
- uniqID = execUniq(script,server,growThreads,target);
- }
- if (weakThreads > 0) {
- script = 'weaken.script';
- uniqID = execUniq(script,server,weakThreads,target);
- }
- // wait for the slowest job to complete (hack < grow < weak)
- while (isRunning(script,server,target,uniqID)) { sleep (1000,false); }
- // if there is a previous sub-job to monitor, wait for it to complete
- if (monID >= 0) {
- monFile = target + monID;
- while (read(monFile) === '') { sleep(1000,false); }
- clear(monFile);
- rm(monFile);
- }
- if (partial) {
- ++monID;
- // if this is a partial sub-job, signal completion to the next sub-job
- write((target + monID),'done');
- } else {
- // if this launch completes an entire job, generate a new job
- run('makejob2.script',1,target);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement