blob: 38f11582885b4839f3d0190ebc1580c52c0ced1b [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
37npm install
38
39if [ -e "releases/${releaseDir}/customSettings.js" ]
40then
41 pid=$(cat releases/$releaseDir/logs/process_pid 2>/dev/null)
42 port=$(cat releases/$releaseDir/customSettings.js|grep uiPort|sed -e 's/[, ]//g'|cut -d: -f2 )
43 count=$(ps -p$pid 2>/dev/null|grep -v PID|wc -l)
44 if [ "$count" != "0" ]
45 then
46 echo "For Release \"$releaseDir\" - http://localhost:$port"
47 echo "********ALREADY RUNNING PID:$pid *******"
48 else
49 pid_listening_on_port=$(netstat -upltn 2>/dev/null|grep -w $port|awk '{print $NF}'|cut -d'/' -f1)
50 if [ "$pid_listening_on_port" != "" ]
51 then
52 if [ "$pid_listening_on_port" != "$pid" ]
53 then
54 echo "port $port is already in use by other process"
55 ps -p $pid_listening_on_port
56 else
57 echo "Process is already running.";
58 fi
59 exit;
60 fi
61 node red.js --settings releases/${releaseDir}/customSettings.js
62 process_pid="$!"
63 echo $process_pid >releases/$releaseDir/logs/process_pid
64 port=$(cat releases/${releaseDir}/customSettings.js|grep uiPort|sed -e 's/[, ]//g'|cut -d: -f2)
65 echo "For Release \"$releaseDir\" ${urlIp}:$port --- STARTED PID:$process_pid"
66 if [ "${releaseDir}" != "" ]
67 then
68 sleep 3
69 ./show_status.sh|grep -w ${releaseDir}
70 fi
71 fi
72else
73 echo "Directory ${releaseDir} is not setup. Use the createReleaseDir.sh script to setup the directory."
74fi