mirror of
https://github.com/Unitech/pm2.git
synced 2026-02-01 16:57:09 +00:00
enable node-args and PM2_NODE_OPTIONS for Fork mode
This commit is contained in:
parent
2a35f5c2ed
commit
d044b2c73d
@ -28,7 +28,8 @@ module.exports = function ForkMode(God) {
|
||||
* @return
|
||||
*/
|
||||
God.forkMode = function forkMode(pm2_env, cb) {
|
||||
var command, args;
|
||||
var command = '';
|
||||
var args = [];
|
||||
|
||||
log('Entering in fork mode');
|
||||
var spawn = require('child_process').spawn;
|
||||
@ -38,16 +39,26 @@ module.exports = function ForkMode(God) {
|
||||
|
||||
if (interpreter !== 'none') {
|
||||
command = interpreter;
|
||||
args = [pm2_env.pm_exec_path];
|
||||
|
||||
if (pm2_env.nodeArgs && Array.isArray(pm2_env.nodeArgs)) {
|
||||
args = args.concat(pm2_env.nodeArgs);
|
||||
}
|
||||
|
||||
if (process.env.PM2_NODE_OPTIONS) {
|
||||
args = args.concat(process.env.PM2_NODE_OPTIONS.split(' '));
|
||||
}
|
||||
|
||||
args.push(pm2_env.pm_exec_path);
|
||||
}
|
||||
else {
|
||||
command = pm2_env.pm_exec_path;
|
||||
args = [ ];
|
||||
}
|
||||
|
||||
// Concat args if present
|
||||
if (pm2_env.args)
|
||||
if (pm2_env.args) {
|
||||
args = args.concat(eval((pm2_env.args)));
|
||||
}
|
||||
|
||||
|
||||
var stdout, stderr;
|
||||
var outFile = pm2_env.pm_out_log_path;
|
||||
|
||||
@ -9,20 +9,35 @@ $pm2 kill
|
||||
echo "################ HARMONY ES6"
|
||||
|
||||
$pm2 start harmony.js
|
||||
sleep 8
|
||||
sleep 2
|
||||
$pm2 list
|
||||
should 'should fail when trying to launch pm2 without harmony option' 'errored' 1
|
||||
ishould 'should not fail when passing harmony option to V8' 'restart_time: 0' 1
|
||||
$pm2 list
|
||||
$pm2 kill
|
||||
|
||||
PM2_NODE_OPTIONS='--harmony' `pwd`/../../bin/pm2 start harmony.js
|
||||
sleep 4
|
||||
sleep 2
|
||||
$pm2 list
|
||||
should 'should not fail when passing harmony option to V8' 'restart_time: 0' 1
|
||||
$pm2 kill
|
||||
|
||||
$pm2 start harmony.js --node-args="--harmony"
|
||||
sleep 8
|
||||
sleep 2
|
||||
$pm2 list
|
||||
should 'should not fail when passing node-args=harmony opts' 'errored' 0
|
||||
should 'should not fail when passing node-args=harmony opts' 'restart_time: 0' 1
|
||||
$pm2 kill
|
||||
|
||||
echo "################ HARMONY / NODEARGS ES6 FORK MODE"
|
||||
|
||||
$pm2 start harmony.js --node-args="--harmony" -x
|
||||
sleep 2
|
||||
$pm2 list
|
||||
should 'should not fail when passing node-args=harmony opts' 'restart_time: 0' 1
|
||||
$pm2 kill
|
||||
|
||||
|
||||
PM2_NODE_OPTIONS='--harmony' $pm2 start harmony.js -x
|
||||
sleep 2
|
||||
$pm2 list
|
||||
should 'should not fail when passing node-args=harmony opts' 'restart_time: 0' 1
|
||||
$pm2 kill
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user