-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature: allow to start raw command via `pm2 start "my command with p…
…arams"` + alias script in ecosystem file with cmd & command
- Loading branch information
Showing
6 changed files
with
116 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#!/usr/bin/env bash | ||
|
||
SRC=$(cd $(dirname "$0"); pwd) | ||
source "${SRC}/../include.sh" | ||
|
||
echo -e "\033[1mRunning tests:\033[0m" | ||
|
||
cd $file_path/start-app | ||
|
||
# | ||
# Direct command | ||
# | ||
$pm2 delete all | ||
|
||
$pm2 start "node -e 'setTimeout(function() { }, 100000); console.log(process.env.TEST)'" -l test.log --merge-logs | ||
should 'should have started command' 'online' 1 | ||
should 'should have not been restarted' 'restart_time: 0' 1 | ||
|
||
cat test.log | grep "undefined" | ||
spec "should have printed undefined env var" | ||
|
||
TEST='ok' $pm2 restart 0 --update-env | ||
cat test.log | grep "ok" | ||
|
||
should 'should have started command' 'online' 1 | ||
should 'should have not been restarted' 'restart_time: 1' 1 | ||
spec "should have printed undefined env var" | ||
|
||
# | ||
# Direct command via Conf file | ||
# | ||
$pm2 delete all | ||
|
||
$pm2 start ecosystem.config.js | ||
should 'should have started command' 'online' 1 | ||
should 'should have not been restarted' 'restart_time: 0' 1 | ||
cat test-conf.log | grep "test_val" | ||
spec "should have printed the test_val" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
module.exports = { | ||
apps : [{ | ||
cmd: "node -e 'setTimeout(function() { }, 100000); console.log(process.env.TEST)'", | ||
log: 'test-conf.log', | ||
merge_logs: true, | ||
env: { | ||
TEST: 'test_val' | ||
} | ||
}] | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
|
||
var http = require('http'); | ||
|
||
var app = http.createServer(function(req, res) { | ||
res.writeHead(200); | ||
res.end('hey'); | ||
}) | ||
|
||
var listener = app.listen(0, function() { | ||
console.log('Listening on port ' + listener.address().port); | ||
}); | ||
|
||
process.on('message', function(msg) { | ||
if (msg == 'shutdown') { | ||
console.log('Closing all connections...'); | ||
setTimeout(function() { | ||
console.log('Finished closing connections'); | ||
process.exit(0); | ||
}, 100); | ||
} | ||
}); |