Skip to content

Instantly share code, notes, and snippets.

@alepez
Last active December 27, 2015 11:59
Show Gist options
  • Save alepez/7322632 to your computer and use it in GitHub Desktop.
Save alepez/7322632 to your computer and use it in GitHub Desktop.
Launch a detached process of node running 'app.js' in the same directory of this script.
#!/usr/bin/env node
var spawn = require('child_process').spawn;
var path = require('path');
var nodeBin = process.execPath;
var appjs = path.resolve(__dirname, 'app.js');
var options = { detached: true, stdio: 'ignore', cwd: __dirname };
var child = spawn(nodeBin, [appjs], options);
child.unref();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment