Skip to content

Commit 6918559

Browse files
authored
update init script, fix config file reference (#49)
1 parent 83673ce commit 6918559

File tree

1 file changed

+31
-9
lines changed
  • rpm/fs/etc/rc.d/init.d

1 file changed

+31
-9
lines changed

rpm/fs/etc/rc.d/init.d/mad

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
# statistics on data and forwards them to upstream aggregation \
88
# services
99
# processname: mad
10-
# config: /opt/mad/config/config.json
10+
# config: /opt/mad/config/config.hocon
1111
# pidfile: /var/run/mad/mad.pid
1212

1313
# Source function library.
@@ -17,15 +17,37 @@ user="mad"
1717
prog="mad"
1818
dir="/opt/mad"
1919
log_dir="$dir/logs"
20-
config="/opt/mad/config/config.json"
21-
logging_config="-Dlogback.configurationFile=/opt/mad/config/logback.xml"
2220
exec="/opt/mad/bin/mad"
2321
pid_file="/var/run/mad/mad.pid"
22+
export CONFIG_FILE="/opt/mad/config/config.hocon"
2423
export JAVA_HOME="$(dirname $(dirname $(readlink -f $(which java))))"
25-
export JAVA_OPTS="$logging_config"
24+
export JVM_XMS="64m"
25+
export JVM_XMX="1024m"
26+
export LOGBACK_CONFIG="-Dlogback.configurationFile=/opt/mad/config/logback.xml"
27+
export ADDITIONAL_JAVA_OPTS=""
28+
export APP_PARAMS="${CONFIG_FILE}"
29+
export ADDITIONAL_APP_PARAMS=""
2630

2731
[ -e /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog
2832

33+
if [ -z "$JAVA_OPTS" ]; then
34+
export JAVA_OPTS="${LOGBACK_CONFIG}\
35+
-XX:+HeapDumpOnOutOfMemoryError \
36+
-XX:HeapDumpPath=/opt/mad/logs/mad.oom.hprof \
37+
-XX:+PrintGCDetails \
38+
-XX:+PrintGCDateStamps \
39+
-Xloggc:logs/mad.gc.log \
40+
-XX:NumberOfGCLogFiles=2 \
41+
-XX:GCLogFileSize=50M \
42+
-XX:+UseGCLogFileRotation \
43+
-Xms${JVM_XMS} \
44+
-Xmx${JVM_XMX} \
45+
-XX:+UseStringDeduplication \
46+
-XX:+UseG1GC \
47+
-Duser.timezone=UTC \
48+
${ADDITIONAL_JAVA_OPTS}"
49+
fi
50+
2951
lockfile=/var/lock/subsys/$prog
3052

3153
get_pid() {
@@ -41,13 +63,13 @@ is_running() {
4163
}
4264

4365
start() {
44-
[ -f $config ] || exit 6
66+
[ -f $CONFIG_FILE ] || exit 6
4567
echo -n $"Starting $prog: "
4668
if is_running; then
47-
warning "$name: already running"
69+
warning "$prog: already running"
4870
else
4971
cd "$dir"
50-
su "$user" -s /bin/sh -c "nice $exec $config >> $log_dir/system.out 2>&1 & echo \$! > $pid_file"
72+
su "$user" -s /bin/sh -c "nice $exec ${APP_PARAMS} ${ADDITIONAL_APP_PARAMS} >> $log_dir/system.out 2>&1 & echo \$! > $pid_file"
5173
if ! is_running; then
5274
failure "$prog did not start"
5375
retval=1
@@ -77,7 +99,7 @@ stop() {
7799
if is_running; then
78100
warning
79101
echo
80-
echo -n "Killing $name: "
102+
echo -n "Killing $prog: "
81103
kill -9 `get_pid`
82104
for i in {1..10}
83105
do
@@ -105,7 +127,7 @@ stop() {
105127
else
106128
warning
107129
echo
108-
echo "$name: not running"
130+
echo "$prog: not running"
109131
if [ -f "$pid_file" ]; then
110132
rm "$pid_file"
111133
fi

0 commit comments

Comments
 (0)