summaryrefslogtreecommitdiffstats
path: root/dgbuilder/stop
blob: 9d0591a476156bbef61274818d55fa9561bb59c8 (plain)
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
51
tbold=$(tput setf 3)
bold=$(tput setf 2)
bold1=$(tput setf 2)
offbold=$(tput rmso;tput sgr0)

function pad {
        #echo "1 is $1 2 is $2"
        if [ "$1" == "" ]
        then
                $1 = "";
        fi
        let count=0
        curr_len=`expr length "$1"`
        let space_length=$2-$curr_len
        spaces=""
        while [ $count -lt $space_length ]
        do
                spaces="$spaces "
                let count=$count+1
        done
        echo "$1$spaces"
}
releaseDir=""
if [ "$#" == "1" ]
then
	releaseDir="$1"
fi

if [ -e "releases/${releaseDir}/customSettings.js" ]
then
		port=$(cat releases/${releaseDir}/customSettings.js|grep uiPort|sed -e 's/[, ]//g'|cut -d: -f2)
	kill $(cat releases/${releaseDir}/logs/process_pid  2>/dev/null) >/dev/null 2>&1
	if [ "$?" != "0" ]
	then
		#kill only if its a node-red process
		processPid=$(netstat -upltn 2>/dev/null|grep -w $port|awk '{print $NF}'|sed -e 's%/node-red%%g')
		kill $processPid 2>/dev/null
		echo "http://localhost:$port ---- STOPPED"
		./show_status|grep -w "${releaseDir}"
	else
		echo "http://localhost:$port ---- STOPPED"
		./show_status|grep -w "${releaseDir}"
	fi
else
	if [ "$releaseDir" != "" ]
	then
		echo "Release Directory ${releaseDir} not setup.";
	else
		echo "Usage:$0 releaseDirName"
	fi	
fi