mirror of
https://github.com/Unitech/pm2.git
synced 2026-02-01 16:57:09 +00:00
Merge branch 'recursive_fix' of https://github.com/chriswiggins/PM2 into development
This commit is contained in:
commit
7fd7efde20
@ -62,6 +62,10 @@
|
||||
{
|
||||
"name": "Michael Hueuberger",
|
||||
"email": "michael.heuberger@binarykitchen.com"
|
||||
},
|
||||
{
|
||||
"name:": "Chris Wiggins",
|
||||
"email": "chris@chriswiggins.co.nz"
|
||||
}
|
||||
],
|
||||
"homepage": "https://github.com/Unitech/pm2",
|
||||
|
||||
40
test/bash/inside-pm2.sh
Normal file
40
test/bash/inside-pm2.sh
Normal file
@ -0,0 +1,40 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
SRC=$(cd $(dirname "$0"); pwd)
|
||||
source "${SRC}/include.sh"
|
||||
|
||||
cd $file_path
|
||||
|
||||
echo -e "\033[1mRunning tests:\033[0m"
|
||||
|
||||
####################################################################
|
||||
# Check that we can start a process from inside a PM2 watched app. #
|
||||
####################################################################
|
||||
|
||||
$pm2 kill
|
||||
|
||||
TEST_VARIABLE='hello1' $pm2 start startProcessInsidePm2.json
|
||||
>inside-out-1.log
|
||||
|
||||
sleep 1
|
||||
|
||||
should 'start master process' 'pm_id: 0' 2
|
||||
|
||||
sleep 1
|
||||
|
||||
$pm2 list
|
||||
|
||||
should 'child process should be started' 'pm_id: 1' 2
|
||||
should 'restarted status should be zero' "restart_time: 0" 2
|
||||
|
||||
grep "hello1" inside-out-1.log &> /dev/null
|
||||
spec "Child should have hello1 variable"
|
||||
|
||||
TEST_VARIABLE='hello2' $pm2 restart "insideProcess"
|
||||
sleep 1
|
||||
grep "hello2" inside-out-1.log &> /dev/null
|
||||
spec "Child should have hello2 variable after restart"
|
||||
|
||||
$pm2 kill
|
||||
|
||||
|
||||
3
test/fixtures/insidePm2Process.js
vendored
Normal file
3
test/fixtures/insidePm2Process.js
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
setInterval(function(){
|
||||
console.log(process.env.TEST_VARIABLE);
|
||||
}, 500);
|
||||
16
test/fixtures/startProcessInsidePm2.js
vendored
Normal file
16
test/fixtures/startProcessInsidePm2.js
vendored
Normal file
@ -0,0 +1,16 @@
|
||||
var pm2 = require('../..');
|
||||
|
||||
pm2.connect(function(err) {
|
||||
if(err){
|
||||
console.log(err);
|
||||
return process.exit(1);
|
||||
}
|
||||
|
||||
pm2.start('./insidePm2Process.js', {name: 'insideProcess', 'output': './inside-out.log', merge_logs: true}, function(err, proc){
|
||||
if(err){
|
||||
console.log(err);
|
||||
return process.exit(1);
|
||||
}
|
||||
console.log(proc);
|
||||
});
|
||||
});
|
||||
7
test/fixtures/startProcessInsidePm2.json
vendored
Normal file
7
test/fixtures/startProcessInsidePm2.json
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
[{
|
||||
"name" : "masterProcess",
|
||||
"script" : "./startProcessInsidePm2.js",
|
||||
"exec_mode" : "fork_mode",
|
||||
"min_uptime" : "100",
|
||||
"max_restarts" : "50"
|
||||
}]
|
||||
@ -56,4 +56,7 @@ spec "Reset meta"
|
||||
bash ./test/bash/startOrX.sh
|
||||
spec "startOrX commands"
|
||||
|
||||
bash ./test/bash/inside-pm2.sh
|
||||
spec "Starting a process inside a PM2 process"
|
||||
|
||||
$pm2 kill
|
||||
|
||||
0
test/server-watch.js
Normal file
0
test/server-watch.js
Normal file
Loading…
x
Reference in New Issue
Block a user