mirror of
https://github.com/Unitech/pm2.git
synced 2025-12-08 20:35:53 +00:00
Merge branch 'development' of https://github.com/Unitech/PM2 into development
This commit is contained in:
commit
8dc66c4b07
5
bin/pm2
5
bin/pm2
@ -33,6 +33,7 @@ commander.version(pkg.version)
|
||||
.option('-e --error <path>', 'specify error log file')
|
||||
.option('-p --pid <pid>', 'specify pid file')
|
||||
.option('--max-memory-restart <memory>', 'specify max memory amount used to autorestart (in megaoctets)')
|
||||
.option('--restart-delay <delay>', 'specify a delay between restarts (in milliseconds)')
|
||||
.option('--env <environment_name>', 'specify environment to get specific env variables (for JSON declaration)')
|
||||
.option('-x --execute-command', 'execute a program using fork system')
|
||||
.option('-u --user <username>', 'define user when generating startup script')
|
||||
@ -48,7 +49,7 @@ commander.version(pkg.version)
|
||||
.option('--no-color', 'skip colors')
|
||||
.option('--no-vizion', 'start an app without vizion feature (versioning control)')
|
||||
.option('--no-autorestart', 'start an app without automatic restart')
|
||||
.option('--no-treekill', 'Only kill main process not detached childrens')
|
||||
.option('--no-treekill', 'Only kill the main process, not detached children')
|
||||
|
||||
.usage('[cmd] app');
|
||||
|
||||
@ -478,7 +479,7 @@ commander.command('startup [platform]')
|
||||
|
||||
//
|
||||
// Logrotate
|
||||
//
|
||||
//
|
||||
commander.command('logrotate')
|
||||
.description('copy default logrotate configuration')
|
||||
.action(function(cmd) {
|
||||
|
||||
@ -112,7 +112,7 @@ Common.prepareAppConf = function(app, cwd, outputter) {
|
||||
/**
|
||||
* Here we put the default exec mode
|
||||
*/
|
||||
if (!app.exec_mode && app.instances > 0) {
|
||||
if (!app.exec_mode && app.instances > 1) {
|
||||
app.exec_mode = 'cluster_mode';
|
||||
} else if (!app.exec_mode) {
|
||||
app.exec_mode = 'fork_mode';
|
||||
|
||||
14
lib/God.js
14
lib/God.js
@ -321,11 +321,17 @@ God.handleExit = function handleExit(clu, exit_code) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!stopping)
|
||||
proc.pm2_env.restart_time += 1;
|
||||
var restart_delay = 0;
|
||||
if (proc.pm2_env.restart_delay !== undefined && !isNaN(parseInt(proc.pm2_env.restart_delay))) {
|
||||
restart_delay = parseInt(proc.pm2_env.restart_delay);
|
||||
}
|
||||
|
||||
if (!stopping && !overlimit)
|
||||
this.executeApp(proc.pm2_env);
|
||||
if (!stopping && !overlimit) {
|
||||
setTimeout(function() {
|
||||
proc.pm2_env.restart_time += 1;
|
||||
God.executeApp(proc.pm2_env);
|
||||
}, restart_delay);
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
|
||||
@ -27,6 +27,9 @@
|
||||
"ext_type": "sbyte",
|
||||
"desc": "it should be a NUMBER - byte, \"[NUMBER]G\"(Gigabyte), \"[NUMBER]M\"(Megabyte) or \"[NUMBER]K\"(Kilobyte)"
|
||||
},
|
||||
"restart_delay": {
|
||||
"type" : "number"
|
||||
},
|
||||
"next_gen_js" : {
|
||||
"type" : "boolean"
|
||||
},
|
||||
|
||||
@ -44,3 +44,11 @@ should 'should process restarted' 'restart_time: 3' 5
|
||||
|
||||
$pm2 reset all
|
||||
should 'should process reseted' 'restart_time: 0' 5
|
||||
|
||||
#
|
||||
# Restart delay test
|
||||
#
|
||||
|
||||
$pm2 delete all
|
||||
$pm2 start killtoofast.js --restart-delay 5000
|
||||
should 'should process not have been restarted yet' 'restart_time: 0' 1
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user