diff --git a/restart.sh b/restart.sh index 454677d..4c5edad 100644 --- a/restart.sh +++ b/restart.sh @@ -8,7 +8,7 @@ fi running=$(./tomcat_ctl.sh status | grep "not running") if [ "x$running" == "x" ]; then printf "Call server command storeall.."; sleep 2 - runcmd result + runcmd result storeall if [ "x$result" == "xsuccess" ] then echo " done!" diff --git a/upgrade-funs.sh b/upgrade-funs.sh index e1bb7d2..8dfe8da 100644 --- a/upgrade-funs.sh +++ b/upgrade-funs.sh @@ -1,10 +1,30 @@ #!/bin/bash +# runcmd sends a command to the running app via the commands.txt / +# status..$pid handshake and blocks until the app reports completion. +# +# Was hardcoded to "storeall" only. Parameterized so the same function can +# drive any command that follows this same protocol - storeall today, +# finishcalls and dumpregistry once those are wired up server-side. +# +# Usage: runcmd [command args...] +# runcmd result storeall +# runcmd result finishcalls 1 +# runcmd result dumpregistry +# +# Requires $pid to already be set in the caller's scope (e.g. pid=$$), +# matching the existing convention in upgrade.sh/restart.sh. function runcmd { - local __resultvar=$1 - sfile="/home/sportrum/webapp/sportrum/WEB-INF/storage/status.storeall.$pid" + local __resultvar=$1 + local cmd=$2 + shift 2 + local cmdargs="$@" + + local storagedir="/home/sportrum/webapp/sportrum/WEB-INF/storage" + local sfile="${storagedir}/status.${cmd}.$pid" + rm -f ${sfile} - printf "storeall $pid" > /home/sportrum/webapp/sportrum/WEB-INF/storage/commands.txt || exit 1 - sfile="/home/sportrum/webapp/sportrum/WEB-INF/storage/status.storeall.$pid" + printf "%s $pid%s" "$cmd" "${cmdargs:+ $cmdargs}" > ${storagedir}/commands.txt || exit 1 + while [ ! -f $sfile ] do sleep 1 diff --git a/upgrade.sh b/upgrade.sh index 3d10c70..100538c 100644 --- a/upgrade.sh +++ b/upgrade.sh @@ -31,7 +31,7 @@ fi running=$(./tomcat_ctl.sh status | grep "tomcat8 is stopped") if [ "x$running" == "x" ]; then printf "Call server command storeall.."; sleep 2 - runcmd result + runcmd result storeall if [ "x$result" == "xsuccess" ] then echo " done!"