Added more to deploy script.

This commit is contained in:
Chris Kleeschulte 2017-10-16 17:44:08 -04:00
parent 70f2518409
commit 63a15d0241
No known key found for this signature in database
GPG Key ID: 33195D27EF6BDB7F
1 changed files with 38 additions and 7 deletions

View File

@ -17,8 +17,14 @@ fi
green="\033[38;5;40m"
magenta="\033[38;5;200m"
lightGreen="\033[38;5;112m"
white="\033[38;5;231m"
mustard="\033[38;5;214m"
grey="\033[38;5;7m"
reset="\033[0m"
ssh="ssh -l${user} -p"
ssh="ssh -tt -l${user} -p"
function execCmd() {
echo -e ${green}$cmd${reset}
@ -30,10 +36,6 @@ function execCmd() {
function deploy () {
# start a subshell to monitor the logs
( eval "${sshCmd}\"${logCmd}\"" ) &
child=$!
# stop the server
cmd="sudo service bitcored stop"
execCmd
@ -49,23 +51,52 @@ function deploy () {
}
function monitor () {
eval "${sshCmd}\"${logCmd}\"" &
}
function closeout () {
PGID=$(ps -o pgid= $$ | grep -o [0-9]*)
kill -- -$PGID
exit 0
}
trap "closeout" SIGINT SIGTERM
while IFS='' read -r server || [[ -n "$server" ]]; do
if [[ "${server}" =~ ^\s*# ]]; then
continue
fi
echo "deploying to: $server"
IFS=':' read -ra url <<< "${server}"
port="${url[1]}"
host="${url[0]}"
logType="${url[2]}"
if [ -z "${port}" ]; then
port=22
fi
if [ -z "${logType}" ]; then
logCmd="sudo journalctl -f"
else
logCmd="sudo tail -f /var/log/upstart/bitcored*"
logCmd="sudo tail -f /var/log/upstart/bitcored_testnet_new.log"
fi
sshCmd="${ssh}${port} ${host} "
monitor
deploy
sleep 10
done < "$1"
wait "${child}"
sleep 240
closeout