feature: allow to set deep monitoring via environment (PM2_DEEP_MONITORING=true on start/restart)

This commit is contained in:
Unitech 2018-02-16 14:00:14 +01:00
parent 748019d1ef
commit eb39c5f697
3 changed files with 34 additions and 0 deletions

View File

@ -668,6 +668,10 @@ API.prototype._startScript = function(script, opts, cb) {
else
app_conf.exec_mode = 'fork';
// Options set via environment variables
if (process.env.PM2_DEEP_MONITORING)
app_conf.deep_monitoring = true;
if (typeof app_conf.name == 'function'){
delete app_conf.name;
}
@ -1450,6 +1454,10 @@ API.prototype._handleAttributeUpdate = function(opts) {
delete appConf.watch
}
// Options set via environment variables
if (process.env.PM2_DEEP_MONITORING)
appConf.deep_monitoring = true;
// Force deletion of defaults values set by commander
// to avoid overriding specified configuration by user
if (appConf.treekill === true)

View File

@ -0,0 +1,24 @@
#!/usr/bin/env bash
SRC=$(cd $(dirname "$0"); pwd)
source "${SRC}/include.sh"
cd $file_path
# With start
$pm2 start echo.js
should 'should deep_monitoring' 'deep_monitoring' 0
$pm2 delete all
PM2_DEEP_MONITORING=true $pm2 start echo.js
should 'should deep_monitoring' 'deep_monitoring' 1
$pm2 delete all
# With restart
$pm2 start echo.js
should 'should deep_monitoring' 'deep_monitoring' 0
PM2_DEEP_MONITORING=true $pm2 restart echo
should 'should deep_monitoring' 'deep_monitoring' 1

View File

@ -23,6 +23,8 @@ bash ./test/bash/pm2-dev.sh
spec "pm2-dev"
bash ./test/bash/pm2-runtime.sh
spec "pm2-runtime"
bash ./test/bash/options-via-env.sh
spec "set option via environment"
bash ./test/bash/startup.sh
spec "upstart startup test"
bash ./test/bash/dump.sh