-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
spring-boot.initd
83 lines (68 loc) · 2.11 KB
/
spring-boot.initd
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
#!/sbin/openrc-run
# vim: set ft=sh: ts=4 sw=4:
# Source: https://github.com/jirutka/spring-boot-openrc
# Version: 0.1.1
: ${name:="$RC_SVCNAME"}
: ${command_user:=${user:-"nobody"}}
: ${retry:="TERM/20/KILL/5"}
command="${JAVA_HOME:+$JAVA_HOME/bin/}java"
command_background="yes"
directory="${jar_file%/*}"
pidfile="/run/$RC_SVCNAME.pid"
if [ "$console_log_file" ]; then
output_log="$console_log_file"
error_log="$console_log_file"
fi
required_files="$jar_file"
depend() {
use net
after localmount firewall
}
start_pre() {
if [ "$RC_SVCNAME" = 'spring-boot' ]; then
eerror ''
eerror 'You are not supposed to run this runscript directly. Instead, you should'
eerror 'create a symlink for the app you want to run as well as a copy of the'
eerror 'configuration file and modify it appropriately, like so:'
eerror ''
eerror ' ln -s spring-boot /etc/init.d/myapp'
eerror ' cp /etc/conf.d/spring-boot /etc/conf.d/myapp'
eerror ''
return 1
fi
if [ "$server_port" ]; then
: ${server_bind_address:="0.0.0.0"}
fi
if [ "$server_port" ] && nc -z "$server_bind_address" "$server_port"; then
eerror "Port $server_port is already in use!"; return 1
fi
local path; for path in "$console_log_file" "$app_log_file"; do
[ -d "${path%/*}" ] || checkpath -o "$command_user" -d "${path%/*}"
checkpath -o "$command_user" -f "$path"
done
java_opts="
-server
${java_classpath:+ -classpath ${java_classpath// /:}}
${java_heap_size:+ -Xms${java_heap_size}M -Xmx${java_heap_size}M}
-Djava.awt.headless=true
-Dfile.encoding=utf-8
$java_opts"
local item; for item in $java_properties; do
java_opts="$java_opts -D${item}"
done
jar_opts="
$(optif --spring.config.location "$config_path")
$(optif --logging.file "$app_log_file")
$(optif --logging.path "${app_log_file%/*}")
$(optif --server.port "$server_port")
$(optif --server.address "$server_bind_address")
$(optif --server.context-path "$context_path")
$jar_opts"
command_args="$java_opts -jar $jar_file $jar_opts"
if yesno "$EINFO_VERBOSE"; then
einfo "Command: $command $(echo $command_args)"
fi
}
optif() {
test -n "$2" && echo "$1=$2"
}