-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathboot.sh
executable file
·80 lines (72 loc) · 1.67 KB
/
boot.sh
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
74
75
76
77
78
79
#!/bin/bash
#
# /etc/.init.d/boot
#boot This shell script takes care of starting and stopping
# boot (Spring boot Application)
#
# Author: Alex Fu
#
# chkconfig: 2345 80 20
# description: boot is the Spring Boot Service daemon.
# Source function library.
. /etc/init.d/functions
JAVA_OPT=-Xmx1024m
JARPATH=/root
JARFILE=`ls -1r $JARPATH/*.jar 2>/dev/null | head -n 1`
PID_FILE=$JARPATH/pid.file
RUNNING=N
if [ -f $PID_FILE ]; then
PID=`cat $PID_FILE`
if [ ! -z "$PID" ] && kill -0 $PID 2>/dev/null; then
RUNNING=Y
fi
fi
start()
{
if [ $RUNNING == "Y" ]; then
echo "Application already started"
else
if [ -z "$JARFILE" ]
then
echo "ERROR: jar file not found"
else
nohup java $JAVA_OPT -Djava.security.egd=file:/dev/./urandom -jar $JARFILE > nohup.out 2>&1 &
echo $! > $PID_FILE
echo "Application $JARFILE starting..."
fi
fi
}
stop()
{
if [ $RUNNING == "Y" ]; then
kill -9 $PID
rm -f $PID_FILE
echo "Application stopped"
else
echo "Application not running"
fi
}
restart()
{
stop
start
}
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status boot
;;
restart)
restart
;;
*)
echo "Usage: $0 { start | stop | restart }"
exit 1
;;
esac
exit $?