Created
January 31, 2019 01:38
-
-
Save zacscoding/2bfdc4fb6abbeadd93bb209cc24e458d to your computer and use it in GitHub Desktop.
boot jar stop shell script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
``` | |
#!/usr/bin/env bash | |
SCRIPT_PATH=$( cd "$(dirname "$0")" ; pwd -P ) | |
WORKING_DIR=$( cd "${SCRIPT_PATH}/../" ; pwd -P ) | |
VERSION="1.0" | |
JAR="MY-JAR-${VERSION}.jar" | |
SERVER_PID_FILE="${WORKING_DIR}/server.pid" | |
if [ -f "${SERVER_PID_FILE}" ]; then | |
if [ -s "${SERVER_PID_FILE}" ]; then | |
SERVER_PID=$(cat ${SERVER_PID_FILE}) | |
PID=$(ps -p ${SERVER_PID} | tail -1 | grep -v grep | grep -v vi | grep -v PID | awk '{print $1}') | |
fi | |
else | |
PID=$(ps -ef | grep ${JAR} | grep -v grep | grep -v vi | grep -v PID | awk '{print $2}') | |
fi | |
if [ ! -z ${PID} ]; then | |
$(kill -9 ${PID}) | |
if [ -f ${SERVER_PID_FILE} ]; then | |
$(rm ${SERVER_PID_FILE}) | |
fi | |
echo "Success to stop ${JAR}" | |
else | |
echo "${JAR} is not running" | |
fi | |
``` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment