Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Reboot example with forever
crontab.load(function(err, tab) {
require('npm').load(function (err, npm) {
if (err) { console.log(err); process.exit(1); }
var path = require('path');
var util = require('util');
var uuid = '322ed3d0-6869-11e1-b86c-0800200c9a66';
var npmPrefix = npm.config.get('prefix');
var npmBinRoot = path.join(npmPrefix, 'bin');
var nodePath = process.execPath.split('/').slice(0, -1).join('/');
var exportCommand = 'export PATH=' + nodePath + ':$PATH';
var foreverCommand = path.join(npmBinRoot, 'forever');
var thisCommand = __filename;
var sysCommand = util.format('%s && %s start %s', exportCommand, foreverCommand, thisCommand);
if (install == true) {
tab.create(sysCommand, uuid).everyReboot();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment