Created
January 3, 2011 03:05
-
-
Save dachev/763076 to your computer and use it in GitHub Desktop.
Reboot example with forever
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
tab.remove(tab.findComment(uuid)); | |
if (install == true) { | |
tab.create(sysCommand, uuid).everyReboot(); | |
} | |
tab.save(); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment