Skip to content

Commit

Permalink
[api] Added forever restartall and forever.restartAll(). Fixes #131
Browse files Browse the repository at this point in the history
  • Loading branch information
indexzero committed Jan 5, 2012
1 parent cef3435 commit 0d5e893
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ You can use forever to run any kind of script continuously (whether it is writte
stop Stop the daemon SCRIPT
stopall Stop all running forever scripts
restart Restart the daemon SCRIPT
restartall Restart all running forever scripts
list List all running forever scripts
config Lists all forever user configuration
set <key> <val> Sets the specified forever config <key>
Expand Down
9 changes: 9 additions & 0 deletions lib/forever.js
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,15 @@ forever.restart = function (target, format) {
return stopOrRestart('restart', 'restart', format, target);
};

//
// ### function restartAll (format)
// #### @format {boolean} Value indicating if we should format output
// Restarts all processes managed by forever.
//
forever.restartAll = function (format) {
return stopOrRestart('restart', 'restartAll', format);
};

//
// ### function stopAll (format)
// #### @format {boolean} Value indicating if we should format output
Expand Down
23 changes: 22 additions & 1 deletion lib/forever/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ var help = [
' stop Stop the daemon SCRIPT',
' stopall Stop all running forever scripts',
' restart Restart the daemon SCRIPT',
' restartall Restart all running forever scripts',
' list List all running forever scripts',
' config Lists all forever user configuration',
' set <key> <val> Sets the specified forever config <key>',
Expand Down Expand Up @@ -78,7 +79,8 @@ var actions = [
'start',
'stop',
'stopall',
'restart',
'restart',
'restartall',
'list',
'config',
'set',
Expand Down Expand Up @@ -268,6 +270,25 @@ app.cmd('stopall', cli.stopall = function () {
});
});

//
// ### function stopall ()
// Stops all currently running forever processes.
//
app.cmd('restartall', cli.restartAll = function () {
var runner = forever.restartAll(true);
runner.on('restartAll', function (processes) {
if (processes) {
forever.log.info('Forever restarted processes:');
processes.split('\n').forEach(function (line) {
forever.log.data(line);
});
}
else {
forever.log.info('No forever processes running');
}
});
});

//
// ### function restart (file)
// #### @file {string} Target process to restart
Expand Down

0 comments on commit 0d5e893

Please sign in to comment.