-
Notifications
You must be signed in to change notification settings - Fork 16
/
server.sh
53 lines (39 loc) · 1.51 KB
/
server.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
#!/bin/bash
# 启动入口类,该脚本文件用于别的项目时要改这里
MAIN_CLASS=com.fuchuan.customerservice.App
COMMAND="$1"
if [[ "$COMMAND" != "start" ]] && [[ "$COMMAND" != "stop" ]] && [[ "$COMMAND" != "restart" ]]; then
echo "./server.sh {start, stop, restart}"
exit 0
fi
# Java 命令行参数,根据需要开启下面的配置,改成自己需要的,注意等号前后不能有空格
# JAVA_OPTS="-Xms256m -Xmx1024m -Dundertow.port=80 -Dundertow.host=0.0.0.0"
# JAVA_OPTS="-Dundertow.port=80 -Dundertow.host=0.0.0.0"
# 生成 class path 值
APP_BASE_PATH=$(cd `dirname $0`; pwd)
CP=${APP_BASE_PATH}/config:${APP_BASE_PATH}/lib/*
function start()
{
# 运行为后台进程,并在控制台输出信息
# java -Xverify:none ${JAVA_OPTS} -cp ${CP} ${MAIN_CLASS} &
# 运行为后台进程,并且不在控制台输出信息
# nohup java -Xverify:none ${JAVA_OPTS} -cp ${CP} ${MAIN_CLASS} >/dev/null 2>&1 &
# 运行为后台进程,并且将信息输出到 output.log 文件
nohup java -Xverify:none ${JAVA_OPTS} -cp ${CP} ${MAIN_CLASS} > output.log &
# 运行为非后台进程,多用于开发阶段,快捷键 ctrl + c 可停止服务
# java -Xverify:none ${JAVA_OPTS} -cp ${CP} ${MAIN_CLASS}
}
function stop()
{
kill `pgrep -f ${MAIN_CLASS}` 2>/dev/null
# 以下代码与上述代码等价
# kill $(pgrep -f ${MAIN_CLASS}) 2>/dev/null
}
if [[ "$COMMAND" == "start" ]]; then
start
elif [[ "$COMMAND" == "stop" ]]; then
stop
else
stop
start
fi