forked from 5kywa1ker/mall
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathboot.sh
90 lines (79 loc) · 1.61 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
80
81
82
83
84
85
86
87
88
89
90
#!/bin/sh
# description: Auto-starts boot
# $API_HOME/bin/boot.sh
#启动命令: boot.sh start
#重启命令: boot.sh restart
#关闭命令: boot.sh stop
#是否运行: boot.sh status
CURRENT_DIR=`dirname $0`
API_HOME=`cd "$CURRENT_DIR/.." >/dev/null; pwd`
# 应用名
Tag="mall"
cd $API_HOME
# 要执行的jar包
Jar="$API_HOME/mall-1.0.jar"
RETVAL="0"
# See how we were called.
start()
{
echo $$ > $API_HOME/api.pid
nohup java \
-XX:-UseGCOverheadLimit \
-verbose:gc -Xloggc:jvm-gc.log \
-Dappliction=$Tag \
-jar $Jar --spring.config.location=$API_HOME/config > $API_HOME/log/api_stdout.log 2>&1 &
echo "$Tag started!"
# 这句是启动后查看控制台输出
tail -f -n 0 $API_HOME/log/api_stdout.log
}
stop()
{
pid=$(ps -ef | grep -v 'grep' | egrep "$Jar"| awk '{printf $2 " "}')
if [ "$pid" != "" ]; then
echo -n "$Tag ( pid: $pid) is running"
echo
echo -n "Shutting down $Tag..."
echo
kill -9 "$pid" > /dev/null 2>&1
fi
status
}
status()
{
pid=$(ps -ef | grep -v 'grep' | egrep "$Jar"| awk '{printf $2 " "}')
#echo "$pid"
if [ "$pid" != "" ]; then
echo "$Tag is running,pid is $pid"
else
echo "$Tag is stopped"
fi
}
usage()
{
echo "Usage: $0 {start|stop|restart|status}"
RETVAL="2"
}
# See how we were called.
RETVAL="0"
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
reload)
RETVAL="3"
;;
status)
status
;;
*)
usage
;;
esac
exit $RETVAL