Skip to content

Commit 5c0b578

Browse files
committed
added tests for file descriptors
1 parent e1e1fdb commit 5c0b578

File tree

4 files changed

+57
-3
lines changed

4 files changed

+57
-3
lines changed

bin/pm2

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -579,13 +579,13 @@ commander.command('prettylist')
579579
commander.command('monit')
580580
.description('launch termcaps monitoring')
581581
.action(function() {
582-
CLI.monit()
582+
CLI.monit();
583583
});
584584

585585
commander.command('m')
586586
.description('(alias) launch termcaps monitoring')
587587
.action(function() {
588-
CLI.monit()
588+
CLI.monit();
589589
});
590590

591591

lib/Monit.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ Monit.reset = function(msg) {
3939

4040
this.multi.charm.reset();
4141

42-
this.multi.write('\x1B[32m⌬ PM2 \x1B[39mmonitoring :\n\n');
42+
this.multi.write('\x1B[32m⌬ PM2 \x1B[39mmonitoring\x1B[96m (To go further check out https://app.keymetrics.io) \x1B[39m\n\n');
4343

4444
if(msg) {
4545
this.multi.write(msg);

test/bash/file-descriptor.sh

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
#!/usr/bin/env bash
2+
3+
SRC=$(cd $(dirname "$0"); pwd)
4+
source "${SRC}/include.sh"
5+
6+
cd $file_path
7+
8+
echo "################## RELOAD ###################"
9+
10+
###############
11+
$pm2 kill
12+
13+
lsof -c PM2 > /tmp/no_pm2_out.dat
14+
15+
$pm2 list
16+
17+
sleep 1
18+
lsof -c PM2 > /tmp/empty_pm2_out.dat
19+
20+
$pm2 start echo.js -i 3
21+
$pm2 start child.js -i 3
22+
$pm2 delete all
23+
24+
sleep 1
25+
lsof -c PM2 > /tmp/empty_pm2_out2.dat
26+
27+
OUT1=`cat /tmp/empty_pm2_out.dat | wc -l`
28+
OUT2=`cat /tmp/empty_pm2_out2.dat | wc -l`
29+
30+
if [ $OUT1 -eq $OUT2 ]; then
31+
success "All file descriptors have been closed"
32+
else
33+
fail "Some file descriptors are still open"
34+
fi
35+
36+
$pm2 start killtoofast.js -i 6
37+
$pm2 kill
38+
39+
sleep 1
40+
lsof -c PM2 > /tmp/no_pm2_out2.dat
41+
diff /tmp/no_pm2_out.dat /tmp/no_pm2_out2.dat
42+
43+
if [ $? == "0" ]; then
44+
success "All file descriptors have been closed"
45+
else
46+
fail "Some file descriptors are still open"
47+
fi
48+
49+
rm /tmp/no_pm2_out.dat
50+
rm /tmp/no_pm2_out2.dat
51+
rm /tmp/empty_pm2_out.dat
52+
rm /tmp/empty_pm2_out2.dat

test/pm2_behavior_tests.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ echo "###################### !DEBUG! ###########################"
1919
# export DEBUG="*"
2020
# fi
2121

22+
bash ./test/bash/file-descriptor.sh
23+
spec "testing file descriptors"
2224
bash ./test/bash/pmx_injection.sh
2325
spec "automatic pmx injection"
2426
bash ./test/bash/log-timestamp.sh

0 commit comments

Comments
 (0)