Skip to content

Commit

Permalink
updated with process keep alive
Browse files Browse the repository at this point in the history
  • Loading branch information
cadebrown committed Sep 23, 2016
1 parent f395654 commit 0a81960
Showing 1 changed file with 29 additions and 23 deletions.
52 changes: 29 additions & 23 deletions PGS.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,6 @@ var queue;
//Progress functions
var reject_funcs;

error("Started running at " + new Date().toString());

if (args.download > 0) {
initFirebase(function () {
downloadWorkloads(args.download)
});
}

//Callback to run.
var callback = function () {
if (args.download > 0) {
Expand All @@ -100,24 +92,35 @@ var callback = function () {
}
}

var start_run = function() {
try {
fs.accessSync(PRIME_FILE);
callback();
} catch (e) {
//Run error
error("Error no prime file! Generating one now.");
error(JSON.stringify(e));
//Spawn
const pp = spawn("./lib.o", [PRIME_FILE]);
//When it closes, handle it
pp.on('close', function (code) {
log(`lib Has finished generating primes.dat`);
callback();
});
}
}

try {
fs.accessSync(PRIME_FILE);
callback();
} catch (e) {
//Run error
error("Error no prime file! Generating one now.");
error(JSON.stringify(e));
//Spawn
const pp = spawn("./lib.o", [PRIME_FILE]);
error("Started running at " + new Date().toString());

//When it closes, handle it
pp.on('close', function (code) {
log(`lib Has finished generating primes.dat`);
callback();
if (args.download > 0) {
initFirebase(function () {
downloadWorkloads(args.download);
});
} else {
start_run();
}


//Main run function
function runOffline() {
log("Running offline using " + prefs.threads + " threads");
Expand Down Expand Up @@ -247,7 +250,7 @@ function downloadWorkloads(n) {
fs.writeFileSync("./workloads/" + getWorkloadIdentifier(data) + ".workload", JSON.stringify(data), 'utf8');
resolve();
if (workloadsDownloaded >= n) {
log("Downloaded workloads");
log("Downloaded all workloads");
shutdown();
}
});
Expand Down Expand Up @@ -372,4 +375,7 @@ function shutdown() {
process.on('SIGINT', function() {
error("SIGINT sent");
shutdown();
});
});

//Keep alive
setInterval(function(){}, Number.POSITIVE_INFINITY);

0 comments on commit 0a81960

Please sign in to comment.