The documentation is not very exhaustive, a bit of additional information.
In the following examples we will use two scripts:
fail-fast.js:
process.exit(1);
fail-slow.js:
setTimeout(() => { process.exit(1); }, 2000);
1) using defaults
forever fail-fast.js
fail-fast.js
script will execute only once, then no other start attempts will be made.
forever fail-slow.js
fail-slow.js
script will be restarted indefinitely, as it stays up more than 1000ms (default value of minUptime
if not specified). You can limit the number of restarts with the -m
parameter.
2) setting only minUptime
forever --minUptime 10000 fail-fast.js
forever --minUptime 10000 fail-slow.js
Both fail-fast.js
and fail-slow.js
will be never be restarted, because we extended minUptime
to 10 seconds and now fail-slow.js
is considered spinning.
3) setting spinSleepTime
Whenever you set spinSleepTime
(with or without minUptime
), your process will restart even if it is considered 'spinning'.
forever --spinSleepTime 30000 fail-fast.js
forever --spinSleepTime 30000 fail-slow.js
Both scripts will be restarted forever, waiting spinSleepTime
milliseconds between restarts.
node SERVER.js
and fix the bug first before starting it with forever.