Skip to content

Instantly share code, notes, and snippets.

@joepie91
Created May 26, 2015 18:07
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joepie91/f81cdbc1b45d52ab4b87 to your computer and use it in GitHub Desktop.
Save joepie91/f81cdbc1b45d52ab4b87 to your computer and use it in GitHub Desktop.
var childProcess = require("child_process");
var electronPath = "./node_modules/electron-prebuilt/dist/electron";
var electronParameters = ["."];
var electronProcess = null;
var electronStopping = false;
startElectron = function(){
electronProcess = childProcess.spawn(electronPath, electronParameters);
electronProcess.stdout.pipe(process.stdout)
electronProcess.on("close", function(code, signal){
if (electronStopping) {
console.log("Restarting electron as requested...");
} else {
console.log("Electron exited with code " + code + ", restarting...");
}
startElectron();
});
}
restartElectron = function(){
if (electronProcess != null) {
electronStopping = true;
electronProcess.kill();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment