blob: 4d3f9f5e127c10eca1fc2e3c8c9b99016afd1b21 [file] [log] [blame]
Timoney, Daniel (dt5972)324ee362017-02-15 10:37:53 -05001releaseDir="$1"
2if [ "$#" != "1" ]
3then
4 echo "Usage: $0 releaseDirName"
5 exit
6fi
7echo "ReleaseDir:$releaseDir"
8export PROJECT_HOME=`pwd`
9tbold=$(tput setf 3)
10bold=$(tput setf 2)
11bold1=$(tput setf 2)
12offbold=$(tput rmso;tput sgr0)
13
14function pad {
15 #echo "1 is $1 2 is $2"
16 if [ "$1" == "" ]
17 then
18 $1 = "";
19 fi
20 let count=0
21 curr_len=`expr length "$1"`
22 let space_length=$2-$curr_len
23 spaces=""
24 while [ $count -lt $space_length ]
25 do
26 spaces="$spaces "
27 let count=$count+1
28 done
29 echo "$1$spaces"
30}
31
32function isRunning {
33 echo $(curl -I "$1" 2>/dev/null|head -1|tail -1|awk '{print $2}')
34}
35
36if [ -e "releases/${releaseDir}/customSettings.js" ]
37then
38 pid=$(cat releases/$releaseDir/logs/process_pid 2>/dev/null)
39 port=$(cat releases/$releaseDir/customSettings.js|grep uiPort|sed -e 's/[, ]//g'|cut -d: -f2 )
40 count=$(ps -p$pid 2>/dev/null|grep -v PID|wc -l)
41 if [ "$count" != "0" ]
42 then
43 echo "For Release \"$releaseDir\" - http://localhost:$port"
44 echo "********ALREADY RUNNING PID:$pid *******"
45 else
46 pid_listening_on_port=$(netstat -upltn 2>/dev/null|grep -w $port|awk '{print $NF}'|cut -d'/' -f1)
47 if [ "$pid_listening_on_port" != "" ]
48 then
49 if [ "$pid_listening_on_port" != "$pid" ]
50 then
51 echo "port $port is already in use by other process"
52 ps -p $pid_listening_on_port
53 else
54 echo "Process is already running.";
55 fi
56 exit;
57 fi
58 node red.js --settings releases/${releaseDir}/customSettings.js
59 process_pid="$!"
60 echo $process_pid >releases/$releaseDir/logs/process_pid
61 port=$(cat releases/${releaseDir}/customSettings.js|grep uiPort|sed -e 's/[, ]//g'|cut -d: -f2)
62 echo "For Release \"$releaseDir\" ${urlIp}:$port --- STARTED PID:$process_pid"
63 if [ "${releaseDir}" != "" ]
64 then
65 sleep 3
66 ./show_status|grep -w ${releaseDir}
67 fi
68 fi
69else
70 echo "Directory ${releaseDir} is not setup. Use the createReleaseDir.sh script to setup the directory."
71fi