Added more to deploy script.
This commit is contained in:
parent
70f2518409
commit
63a15d0241
|
@ -17,8 +17,14 @@ fi
|
||||||
|
|
||||||
green="\033[38;5;40m"
|
green="\033[38;5;40m"
|
||||||
magenta="\033[38;5;200m"
|
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"
|
reset="\033[0m"
|
||||||
ssh="ssh -l${user} -p"
|
ssh="ssh -tt -l${user} -p"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function execCmd() {
|
function execCmd() {
|
||||||
echo -e ${green}$cmd${reset}
|
echo -e ${green}$cmd${reset}
|
||||||
|
@ -30,10 +36,6 @@ function execCmd() {
|
||||||
|
|
||||||
function deploy () {
|
function deploy () {
|
||||||
|
|
||||||
# start a subshell to monitor the logs
|
|
||||||
( eval "${sshCmd}\"${logCmd}\"" ) &
|
|
||||||
child=$!
|
|
||||||
|
|
||||||
# stop the server
|
# stop the server
|
||||||
cmd="sudo service bitcored stop"
|
cmd="sudo service bitcored stop"
|
||||||
execCmd
|
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
|
while IFS='' read -r server || [[ -n "$server" ]]; do
|
||||||
|
if [[ "${server}" =~ ^\s*# ]]; then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
echo "deploying to: $server"
|
echo "deploying to: $server"
|
||||||
|
|
||||||
IFS=':' read -ra url <<< "${server}"
|
IFS=':' read -ra url <<< "${server}"
|
||||||
|
|
||||||
port="${url[1]}"
|
port="${url[1]}"
|
||||||
host="${url[0]}"
|
host="${url[0]}"
|
||||||
logType="${url[2]}"
|
logType="${url[2]}"
|
||||||
|
|
||||||
if [ -z "${port}" ]; then
|
if [ -z "${port}" ]; then
|
||||||
port=22
|
port=22
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -z "${logType}" ]; then
|
if [ -z "${logType}" ]; then
|
||||||
logCmd="sudo journalctl -f"
|
logCmd="sudo journalctl -f"
|
||||||
else
|
else
|
||||||
logCmd="sudo tail -f /var/log/upstart/bitcored*"
|
logCmd="sudo tail -f /var/log/upstart/bitcored_testnet_new.log"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
sshCmd="${ssh}${port} ${host} "
|
sshCmd="${ssh}${port} ${host} "
|
||||||
|
|
||||||
|
monitor
|
||||||
deploy
|
deploy
|
||||||
|
|
||||||
|
sleep 10
|
||||||
done < "$1"
|
done < "$1"
|
||||||
|
|
||||||
wait "${child}"
|
sleep 240
|
||||||
|
closeout
|
||||||
|
|
Loading…
Reference in New Issue