Created
January 31, 2019 01:38
Revisions
-
zacscoding created this gist
Jan 31, 2019 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,29 @@ ``` #!/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 ```