forked from appirio-tech/tc-api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
testAndKill.sh
50 lines (34 loc) · 817 Bytes
/
testAndKill.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/bin/bash
# kill the currently running Node.JS process
safeRunCommand() {
typeset cmnd="$*"
typeset ret_code
echo cmnd=$cmnd
eval $cmnd
exitcode=$?
}
environment="$1"
if [[ "$environment" = "" ]]
then
environment = "ci"
fi
source "./deploy/${environment}.sh"
safeRunCommand "npm install"
safeRunCommand "npm start"
sleep 5
safeRunCommand "npm test"
echo "exit code ${exitcode}"
sleep 3
# find the processes
echo searching for processes....
sockproc=$(ps -efww | grep "node_modules" | grep -v grep |grep $USER | cut -c9-14)
echo processes $sockproc
# if they are not blank, kill them
if [[ -n $sockproc ]]; then
echo killing $sockproc ...
kill -9 $sockproc
echo "kill -9 ${sockproc}"
else
echo "Node process was not found."
fi
exit ${exitcode}