Chinthakayala, Sheshashailavas (sc2914) | d156997 | 2017-08-28 05:25:46 -0900 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | releaseDir="$1" |
| 3 | if [ "$#" != "1" ] |
| 4 | then |
| 5 | echo "Usage: $0 releaseDirName" |
| 6 | exit |
| 7 | fi |
| 8 | echo "ReleaseDir:$releaseDir" |
| 9 | export PROJECT_HOME=`pwd` |
| 10 | tbold=$(tput setf 3) |
| 11 | bold=$(tput setf 2) |
| 12 | bold1=$(tput setf 2) |
| 13 | offbold=$(tput rmso;tput sgr0) |
| 14 | |
| 15 | function 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 | |
| 33 | function isRunning { |
| 34 | echo $(curl -I "$1" 2>/dev/null|head -1|tail -1|awk '{print $2}') |
| 35 | } |
| 36 | |
Chinthakayala, Sheshashailavas (sc2914) | d156997 | 2017-08-28 05:25:46 -0900 | [diff] [blame] | 37 | if [ -e "releases/${releaseDir}/customSettings.js" ] |
| 38 | then |
| 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 |
| 70 | else |
| 71 | echo "Directory ${releaseDir} is not setup. Use the createReleaseDir.sh script to setup the directory." |
| 72 | fi |