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