|
|
|
@ -4,18 +4,23 @@ DIR=$(readlink -e "$(dirname "$0")")
|
|
|
|
|
PROD_SERVER_JAR_NAME="server-prod.jar"
|
|
|
|
|
NEW_SERVER_JAR_NAME="server-all.jar"
|
|
|
|
|
|
|
|
|
|
OLD_PID=$(ps -aux | tr -s " " | grep -E "\bjava -jar $PROD_SERVER_JAR_NAME\b" | cut -d " " -f2)
|
|
|
|
|
#if $OLD_PID is not empty but isn't a number, something went wrong
|
|
|
|
|
if [ "$OLD_PID" ] && ! echo "$OLD_PID" | grep -E -q "^[0-9]+$"; then
|
|
|
|
|
echo "error, unable to retrieve old server pid: $OLD_PID" >&2
|
|
|
|
|
prod_pid() {
|
|
|
|
|
ps -aux | tr -s " " | grep -E "\bjava -jar $PROD_SERVER_JAR_NAME\b" | cut -d " " -f2
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
PROD_PID=$(prod_pid)
|
|
|
|
|
|
|
|
|
|
#if $PROD_PID is not empty but isn't a number, something went wrong
|
|
|
|
|
if [ "$PROD_PID" ] && ! echo "$PROD_PID" | grep -E -q "^[0-9]+$"; then
|
|
|
|
|
echo "error, unable to retrieve old server pid: $PROD_PID" >&2
|
|
|
|
|
exit 2
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
if [ "$OLD_PID" ]; then
|
|
|
|
|
if [ "$PROD_PID" ]; then
|
|
|
|
|
#will cause the old server to gracefully shutdown
|
|
|
|
|
echo "shutting down old server version ..."
|
|
|
|
|
kill -s SIGQUIT "$OLD_PID"
|
|
|
|
|
while ! kill -s 0 "$OLD_PID"; do sleep 1; done #sleep until process ends
|
|
|
|
|
kill -s SIGQUIT "$PROD_PID"
|
|
|
|
|
while [ ! "$(prod_pid)" ]; do sleep 1; done #sleep until process ends
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
rm "$DIR/$PROD_SERVER_JAR_NAME"
|
|
|
|
|