Skip to content

Commit

Permalink
feature: allow to set deep monitoring via environment (PM2_DEEP_MONIT…
Browse files Browse the repository at this point in the history
…ORING=true on start/restart)
  • Loading branch information
Unitech committed Feb 16, 2018
1 parent 748019d commit eb39c5f
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/API.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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)
Expand Down
24 changes: 24 additions & 0 deletions test/bash/options-via-env.sh
Original file line number Diff line number Diff line change
@@ -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
2 changes: 2 additions & 0 deletions test/pm2_behavior_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit eb39c5f

Please sign in to comment.