Merge pull request #509 from staeke/development

Adding configuration option max_restarts to allow min_update to work properly
This commit is contained in:
soyuka 2014-06-22 20:31:47 +02:00
commit 7bf812c155

View File

@ -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