forked from posoni324/springboot-execute-with-shell
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathspringboot.sh
More file actions
73 lines (68 loc) · 1.35 KB
/
springboot.sh
File metadata and controls
73 lines (68 loc) · 1.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/bin/bash
# chkconfig 2345 20 80
# written by Gavin Kim on 2018.05.18
readonly PROC_NAME="springboot"
readonly DAEMON="/springboot-0.0.1-SNAPSHOT.jar"
readonly PID_PATH="/springboot"
readonly PROC_PID="${PID_PATH}${PROC_NAME}.pid"
start()
{
echo "Starting ${PROC_NAME}..."
local PID=$(get_status)
if [ -n "${PID}" ]; then
echo "${PROC_NAME} is already running"
exit 0
fi
nohup java -jar -XX:MaxPermSize=128m -Xms512m -Xmx1024m "${DAEMON}" > /dev/null 2>&1 &
local PID=${!}
if [ -n ${PID} ]; then
echo " - Starting..."
echo " - Created Process ID in ${PROC_PID}"
echo ${PID} > ${PROC_PID}
else
echo " - failed to start."
fi
}
stop()
{
echo "Stopping ${PROC_NAME}..."
local DAEMON_PID=`cat "${PROC_PID}"`
if [ "$DAEMON_PID" -lt 3 ]; then
echo "${PROC_NAME} was not running."
else
kill $DAEMON_PID
rm -f $PROC_PID
echo " - Shutdown ...."
fi
}
status()
{
local PID=$(get_status)
if [ -n "${PID}" ]; then
echo "${PROC_NAME} is running"
else
echo "${PROC_NAME} is stopped"
# start daemon
#nohup java -jar "${DAEMON}" > /dev/null 2>&1 &
fi
}
get_status()
{
ps ux | grep ${PROC_NAME} | grep -v grep | awk '{print $2}'
}
case "$1" in
start)
start
sleep 7
;;
stop)
stop
sleep 5
;;
status)
status "${PROC_NAME}"
;;
*)
echo "Usage: $0 {start | stop | status }"
esac
exit 0