Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mreis1/faa379e6b3354becbc1cbe17cca7343d to your computer and use it in GitHub Desktop.
Save mreis1/faa379e6b3354becbc1cbe17cca7343d to your computer and use it in GitHub Desktop.
Restart itself (node.js app) https://stackoverflow.com/questions/25247250
#!/usr/bin/env node
"use strict";
console.log("This is pid " + process.pid);
setTimeout(function () {
process.on("exit", function () {
require("child_process").spawn(process.argv.shift(), process.argv, {
cwd: process.cwd(),
detached : true,
stdio: "inherit"
});
});
process.exit();
}, 5000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment