Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/reload.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ cluster(server)
.set('workers', 1)
.use(cluster.reload())
.use(cluster.debug())
.listen(3000);
.listen(3000);
7 changes: 7 additions & 0 deletions lib/master.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ var node = process.execPath;
* which can be patched in order to preserve plugin state.
* - `restart`. Restart complete, new master established, previous died.
* Receives an object with state preserved by the `restarting` event.
* - `exit`. When a restarted master process exits.
*
* Signals:
*
Expand Down Expand Up @@ -684,6 +685,12 @@ Master.prototype.spawnMaster = function(){
customFds: customFds
, env: env
});

// watch for exit in case of problem during restart
var self = this;
proc.on('exit',function(){
self.emit('exit',{});
});

// unix domain socket for ICP + fd passing
proc.sock = new net.Socket(fds[1], 'unix');
Expand Down
7 changes: 6 additions & 1 deletion lib/plugins/reload.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,16 @@ exports = module.exports = function(files, options){
master.on('restarting', function(){
restarting = true;
});

master.on('exit', function(){
// must have been a problem
restarting = false;
});
}
};

/**
* Directories to ignore.
*/

exports.ignoreDirectories = ['node_modules', 'support', 'test', 'bin'];
exports.ignoreDirectories = ['node_modules', 'support', 'test', 'bin'];