Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Make forever safer for servers #344

Closed
wants to merge 2 commits into from

2 participants

@ghost

I have run into a number of gotchas in the past arising from:

  • Scripts with a typo that fail on start, and becoming hard to stop
  • Scripts named like command names.

I resolved this by forcing the command parameter, and adding defaults to both minUptime and max.

Kinda defeats some of the simple use cases, but making the program safer by default could be a good idea.

@Redsandro

How does this work? I noticed an uncatched error in a script that wasn't noticed before caught node in a crashloop, making node+mongodb use 100% cpu because forever would restart the script the next clockcycle it was crashed.

There should be a grace-period for restarting or something.

@indexzero indexzero closed this in 055c483
@indexzero
Owner

I like your idea of warning people, but we can't change the CLI behavior this dramatically.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Oct 7, 2012
  1. Forever command is now a required parameter

    Alexander Stokes authored
This page is out of date. Refresh to see the latest.
Showing with 19 additions and 9 deletions.
  1. +19 −9 lib/forever/cli.js
View
28 lib/forever/cli.js
@@ -189,12 +189,25 @@ var getOptions = cli.getOptions = function (file) {
[
'pidFile', 'logFile', 'errFile', 'watch', 'minUptime', 'append',
- 'silent', 'outFile', 'max', 'command', 'path', 'spinSleepTime',
+ 'silent', 'max', 'outFile', 'command', 'path', 'spinSleepTime',
'sourceDir', 'uid', 'watchDirectory'
].forEach(function (key) {
options[key] = app.config.get(key);
});
+ if (!options.max) {
+ forever.log.info('Forever should be started with -m MAX parameter.')
+ forever.log.info('Forever running MAX 1 time.')
+ options.max = 1
+ }
+
+ if (!options.minUptime) {
+ forever.log.info('Forever can be started with -minUptime parameter.')
+ forever.log.info('Starting child process with -minUptime 1000')
+ options.minUptime = 1000
+ }
+
+
options.sourceDir = options.sourceDir || (file && file[0] !== '/' ? process.cwd() : '/');
if (options.sourceDir) {
options.spawnWith = {cwd: options.sourceDir};
@@ -491,16 +504,13 @@ app.cmd('help', cli.help = function () {
// Remark: this regex matches everything. It has to be added at the end to
// make executing other commands possible.
//
+
cli.run = function () {
- var file = app.argv._[0],
- options = getOptions(file);
+ var file = app.argv._[0];
+
+ forever.log.error('\''+file+'\' is not a forever command. See \'forever --help\'.');
+ forever.log.info('Did you mean this?\n start '+ file);
- tryStart(file, options, function () {
- var monitor = forever.start(file, options);
- monitor.on('start', function () {
- forever.startServer(monitor);
- });
- });
};
cli.start = function () {
Something went wrong with that request. Please try again.