Added more to deploy script.
This commit is contained in:
parent
70f2518409
commit
63a15d0241
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue