-
-
Save DenisGorbachev/523f3a937faec86b31dd to your computer and use it in GitHub Desktop.
PM2 test output
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
starfall@nx:~/workspace/PM2$ bash test/bash/watch.sh | |
$pm2 kill | |
[PM2] Stopping PM2... | |
[PM2] deleteProcessId process id 0 | |
[PM2][WARN] No process found | |
[PM2] All processes have been stopped and deleted | |
[PM2] PM2 stopped | |
# Determine wget / curl | |
which wget > /dev/null | |
if [ $? -eq 0 ] | |
then | |
http_get="wget" | |
else | |
echo -e "\033[31mYou need wget to run this test \033[0m"; | |
exit 1; | |
fi | |
function fail { | |
echo -e "######## \033[31m ✘ $1\033[0m" | |
exit 1 | |
} | |
function success { | |
echo -e "\033[32m------------> ✔ $1\033[0m" | |
} | |
function spec { | |
RET=$? | |
sleep 0.3 | |
[ $RET -eq 0 ] || fail "$1" | |
success "$1" | |
} | |
function ispec { | |
RET=$? | |
sleep 0.3 | |
[ $RET -ne 0 ] || fail "$1" | |
success "$1" | |
} | |
function should { | |
sleep 0.5 | |
$pm2 prettylist > /tmp/tmp_out.txt | |
OUT=`cat /tmp/tmp_out.txt | grep -o "$2" | wc -l` | |
[ $OUT -eq $3 ] || fail "$1" | |
success "$1" | |
} | |
function shouldnot { | |
sleep 0.5 | |
$pm2 prettylist > /tmp/tmp_out.txt | |
OUT=`cat /tmp/tmp_out.txt | grep -o "$2" | wc -l` | |
[ $OUT -ne $3 ] || fail "$1" | |
success "$1" | |
} | |
cd $file_path | |
function waituntil { | |
for (( i = 0; i <= $1; i++ )); do | |
sleep 0.2 | |
echo -n "." | |
done | |
echo "" | |
} | |
echo -e "\033[1mRunning tests:\033[0m" | |
Running tests: | |
##################### | |
# Watch for changes # | |
##################### | |
>server-watch.js | |
$pm2 kill | |
[PM2] Spawning PM2 daemon | |
[PM2] PM2 Successfully daemonized | |
[PM2][Module] Starting module pm2-probe | |
[PM2] Stopping PM2... | |
[PM2][WARN] No process found | |
[PM2] All processes have been stopped and deleted | |
[PM2] Process launched | |
[PM2] PM2 stopped | |
cp server-watch.bak.js server-watch.js | |
$pm2 start server-watch.js --watch | |
[PM2] Spawning PM2 daemon | |
[PM2] PM2 Successfully daemonized | |
[PM2][Module] Starting module pm2-probe | |
[PM2] Starting server-watch.js in fork_mode (1 instance) | |
[PM2] Process launched | |
[PM2] Done. | |
┌──────────────┬────┬──────┬───────┬────────┬─────────┬────────┬────────────┬──────────┐ | |
│ App name │ id │ mode │ pid │ status │ restart │ uptime │ memory │ watching │ | |
├──────────────┼────┼──────┼───────┼────────┼─────────┼────────┼────────────┼──────────┤ | |
│ server-watch │ 1 │ fork │ 18925 │ online │ 0 │ 0s │ 7.922 MB │ enabled │ | |
└──────────────┴────┴──────┴───────┴────────┴─────────┴────────┴────────────┴──────────┘ | |
Module activated | |
┌───────────┬─────────┬────────────┬────────┬─────────┬─────┬─────────────┐ | |
│ Module │ version │ target PID │ status │ restart │ cpu │ memory │ | |
├───────────┼─────────┼────────────┼────────┼─────────┼─────┼─────────────┤ | |
│ pm2-probe │ N/A │ 18920 │ online │ 0 │ 5% │ 11.805 MB │ | |
└───────────┴─────────┴────────────┴────────┴─────────┴─────┴─────────────┘ | |
Use `pm2 show <id|name>` to get more details about an app | |
should 'process should be watched' 'watch: true' 1 | |
cat /tmp/tmp_out.txt | grep -o "$2" | wc -l | |
------------> ✔ process should be watched | |
echo "console.log('test');" >> server-watch.js | |
sleep 1 | |
cat server-watch.js | |
var http = require('http'); | |
http.createServer(function(req, res) { | |
res.writeHead(200); | |
res.end('hey'); | |
}).listen(8000); | |
console.log('test'); | |
$pm2 list | |
┌──────────────┬────┬──────┬───────┬────────┬─────────┬────────┬─────────────┬──────────┐ | |
│ App name │ id │ mode │ pid │ status │ restart │ uptime │ memory │ watching │ | |
├──────────────┼────┼──────┼───────┼────────┼─────────┼────────┼─────────────┼──────────┤ | |
│ server-watch │ 1 │ fork │ 18976 │ online │ 1 │ 1s │ 17.652 MB │ enabled │ | |
└──────────────┴────┴──────┴───────┴────────┴─────────┴────────┴─────────────┴──────────┘ | |
Module activated | |
┌───────────┬─────────┬────────────┬────────┬─────────┬─────┬─────────────┐ | |
│ Module │ version │ target PID │ status │ restart │ cpu │ memory │ | |
├───────────┼─────────┼────────────┼────────┼─────────┼─────┼─────────────┤ | |
│ pm2-probe │ 1.1.0 │ 18920 │ online │ 0 │ 99% │ 36.465 MB │ | |
└───────────┴─────────┴────────────┴────────┴─────────┴─────┴─────────────┘ | |
Use `pm2 show <id|name>` to get more details about an app | |
should 'process should have been restarted' 'restart_time: 1' 1 | |
cat /tmp/tmp_out.txt | grep -o "$2" | wc -l | |
------------> ✔ process should have been restarted | |
should 'process should be online' "status: 'online'" 1 | |
cat /tmp/tmp_out.txt | grep -o "$2" | wc -l | |
######## ✘ process should be online |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment