Skip to content

Commit

Permalink
[fix] inherits configuration from parent process when using `startDae…
Browse files Browse the repository at this point in the history
…mon` method.
  • Loading branch information
Tjatse committed Oct 30, 2014
1 parent 521d91a commit 1102d11
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions bin/monitor
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ 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());

// inherits configuration from parent process if exists.
options && options.__loaded_options && (forever.load(options.__loaded_options), delete options.__loaded_options);

if (!started) {
started = true;
start(options);
Expand Down
6 changes: 6 additions & 0 deletions lib/forever.js
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,9 @@ function stopOrRestart(action, event, format, target) {
// Initializes configuration for forever module
//
forever.load = function (options) {
// memorize current options.
this.__loaded_options = options;

//
// Setup the incoming options with default options.
//
Expand Down Expand Up @@ -410,6 +413,9 @@ forever.startDaemon = function (script, options) {
console.error('Monitor died unexpectedly with exit code %d', code);
});

// transmit options to daemonic(child) process, keep configuration lineage.
options.__loaded_options = this.__loaded_options;

monitor.send(JSON.stringify(options));

// close the ipc communication channel with the monitor
Expand Down

0 comments on commit 1102d11

Please sign in to comment.