-
Notifications
You must be signed in to change notification settings - Fork 944
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[refactor] Refactor to remove daemon.node
This replaces the addon with the new child process API in node core. This branch is for node 0.8.x only - 0.6.x support will be continued as a separate release series.
- Loading branch information
Showing
4 changed files
with
56 additions
and
18 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#! /usr/bin/env node | ||
|
||
var path = require('path'), | ||
forever = require(path.resolve(__dirname, '..', 'lib', 'forever')), | ||
started; | ||
|
||
|
||
|
||
process.on('message', function (data) { | ||
// TODO: Find out if this data will ever get split into two message events. | ||
var options = JSON.parse(data.toString()); | ||
if (!started) { | ||
started = true; | ||
start(options); | ||
} | ||
}); | ||
|
||
function start(options) { | ||
var script = process.argv[2], | ||
monitor = new forever.Monitor(script, options); | ||
|
||
monitor.start(); | ||
|
||
monitor.on('start', function () { | ||
// This starts an nssocket server, which the forever CLI uses to | ||
// communicate with this monitor process after it's detached. | ||
// Without this, `forever list` won't show the process, even though it | ||
// would still be running in the background unaffected. | ||
forever.startServer(monitor); | ||
// Disconnect the IPC channel, letting this monitor's parent process know | ||
// that the child has started successfully. | ||
process.disconnect(); | ||
}); | ||
} |
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
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
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