-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjava-project-system.sh
81 lines (68 loc) · 1.51 KB
/
java-project-system.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
#!/bin/bash
# system path
#SYSTEM_PATH=$(dirname $(readlink -f "$0"))
SYSTEM_PATH="/web"
JAVA_HOME="$SYSTEM_PATH/jdk-17.0.4+8"
PROJECT_NAME="system-web-0.0.1-SNAPSHOT.jar"
export JAVA_HOME
PATH="$JAVA_HOME/bin:$PATH"
export PATH
java -version
echo "start server...."
echo $SYSTEM_PATH
pid_file="$SYSTEM_PATH/$PROJECT_NAME".pid
function dev() {
java -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5005 -jar "$SYSTEM_PATH/$PROJECT_NAME" --spring.config.location="$SYSTEM_PATH"/config/application.yml
java_start
}
function noHupLog() {
nohup java -jar "$SYSTEM_PATH/$PROJECT_NAME" --spring.config.location="$SYSTEM_PATH"/config/application.yml >"$SYSTEM_PATH"/log.log &
java_start
}
function noHupNoLog() {
nohup java -jar "$SYSTEM_PATH/$PROJECT_NAME" --spring.config.location="$SYSTEM_PATH"/config/application.yml >/dev/null 2>&1 &
java_start
}
function java_start() {
# shellcheck disable=SC2181
if [[ $? -eq 0 ]]; then
echo $! > ${pid_file}
else exit 1
fi
}
function java_stop() {
# shellcheck disable=SC2046
# kill -9 $(cat ${pid_file})
kill $(cat ${pid_file})
# shellcheck disable=SC2181
if [[ $? -eq 0 ]]; then
rm -f ${pid_file}
else exit 1
fi
echo "java stop ok"
}
case "$1" in
dev)
dev
;;
log)
noHupLog
;;
start)
noHupNoLog
;;
stop)
java_stop
;;
status)
redis_status
;;
restart|reload)
java_stop
sleep 1
noHupNoLog
;;
*)
echo "Please use start or stop as first argument"
;;
esac