Skip to content

Commit

Permalink
[fix] use node-fork for listing
Browse files Browse the repository at this point in the history
  • Loading branch information
bmeck authored and indexzero committed Jan 5, 2012
1 parent fa02258 commit 1f673f9
Showing 1 changed file with 22 additions and 9 deletions.
31 changes: 22 additions & 9 deletions lib/forever.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ var fs = require('fs'),
path = require('path'),
events = require('events'),
exec = require('child_process').exec,
fork = require('child_process').fork,
spawn = require('child_process').spawn,
cliff = require('cliff'),
nconf = require('nconf'),
Expand Down Expand Up @@ -365,15 +364,29 @@ forever.startDaemon = function (script, options, callback) {
options.logFile = forever.logFilePath(options.logFile || options.uid + '.log');
options.pidFile = forever.pidFilePath(options.pidFile || options.uid + '.pid');

if (!process.send) {
fork(process.argv[1], process.argv.slice(2), {env: process.env});
process.exit(0);
}
else {
var monitor = new forever.Monitor(script, options);
var monitor = new forever.Monitor(script, options);

fs.open(options.logFile, options.appendLog ? 'a+' : 'w+', function (err, fd) {
if (err) {
return monitor.emit('error', err);
}

var pid = daemon.start(fd);
daemon.lock(options.pidFile);

//
// Remark: This should work, but the fd gets screwed up
// with the daemon process.
//
// process.on('exit', function () {
// fs.unlinkSync(options.pidFile);
// });

process.pid = pid;
monitor.start();
return monitor;
}
});

return monitor;
};

//
Expand Down

0 comments on commit 1f673f9

Please sign in to comment.