mirror of
https://github.com/Unitech/pm2.git
synced 2026-02-01 16:57:09 +00:00
Merge pull request #509 from staeke/development
Adding configuration option max_restarts to allow min_update to work properly
This commit is contained in:
commit
7bf812c155
12
lib/God.js
12
lib/God.js
@ -90,14 +90,18 @@ function handleExit(clu, exit_code) {
|
||||
* Avoid infinite reloop if an error is present
|
||||
*/
|
||||
// If the process has been created less than 15seconds ago
|
||||
if ((Date.now() - clu.pm2_env.created_at) < 15000) {
|
||||
// And if the process has an uptime less than a second
|
||||
if ((Date.now() - clu.pm2_env.pm_uptime) < (clu.pm2_env.min_uptime || 1000)) {
|
||||
|
||||
// And if the process has an uptime less than a second
|
||||
var min_uptime = (clu.pm2_env.min_uptime || 1000);
|
||||
var max_restarts = (clu.pm2_env.max_restarts || 15);
|
||||
|
||||
if ((Date.now() - clu.pm2_env.created_at) < (min_uptime * max_restarts)) {
|
||||
if ((Date.now() - clu.pm2_env.pm_uptime) < min_uptime) {
|
||||
// Increment unstable restart
|
||||
clu.pm2_env.unstable_restarts += 1;
|
||||
}
|
||||
|
||||
if (clu.pm2_env.unstable_restarts >= 15) {
|
||||
if (clu.pm2_env.unstable_restarts >= max_restarts) {
|
||||
// Too many unstable restart in less than 15 seconds
|
||||
// Set the process as 'ERRORED'
|
||||
// And stop to restart it
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user