summaryrefslogtreecommitdiff
path: root/sysutils/graylog/files/graylog.in
blob: 3530a2a57120d1f18eeaa4eb3aea56d30886f1fa (plain)
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
#!/bin/sh
#
# PROVIDE: graylog
# REQUIRE: NETWORKING SERVERS
# BEFORE: DAEMON
# KEYWORD: shutdown
#

# graylog_enable (bool):
#   Default value: "NO"
#   Flag that determines whether graylog is enabled
#
# graylog_user (username):
#   Default value: "graylog"
#   Name of the graylog user account
#
# graylog_group (group):
#   Default value: "graylog"
#   Name of the graylog group
#
# graylog_config (string)
#   Default value %%ETCDIR%%/server/server.conf
#   Path to the graylog configuration file
#
# graylog_min_mem (string):
#   Default value: 256m
#   Minumum JVM heap size
#
# graylog_max_mem (string):
#   Default value: 1g
#   Maximum JVM heap size
#
# graylog_dir (string):
#   Default value: %%DATADIR%%
#   Path to the graylog installation.
#
# graylog_data_dir (string):
#   Default vaule: %%GRAYLOG_DATA_DIR%%
#   Storage location for the graylog journal
#
# graylog_run_dir (string):
#   Default value: /var/graylog
#   Path to the graylog run folder.
#
# graylog_log_config (string):
#   Default value: %%ETCDIR%%/server/log4j2.xml
#   Path to the Graylog Server logfile

. /etc/rc.subr

name=graylog
rcvar=graylog_enable
load_rc_config $name

: ${graylog_enable:="NO"}
: ${graylog_user:="%%GRAYLOGUSER%%"}
: ${graylog_group:="%%GRAYLOGGROUP%%"}
: ${graylog_config:="%%ETCDIR%%/graylog.conf"}
: ${graylog_min_mem:="256m"}
: ${graylog_max_mem:="1g"}
: ${graylog_dir:="%%DATADIR%%"}
: ${graylog_data_dir:="%%GRAYLOG_DATA_DIR%%"}
: ${graylog_logs_dir:="%%GRAYLOG_LOGS_DIR%%"}
: ${graylog_run_dir:="/var/run/graylog"}
: ${graylog_log_config:="%%ETCDIR%%/log4j2.xml"}

java_options=" \
    -Djava.awt.headless=true \
    -Dapp=${name} \
    -Dlog4j.configurationFile=${graylog_log_config} \
    -Xms${graylog_min_mem} \
    -Xmx${graylog_max_mem} \
    -XX:-OmitStackTraceInFastThrow \
    -XX:+AggressiveOpts \
    -XX:+CMSClassUnloadingEnabled \
    -XX:+CMSConcurrentMTEnabled \
    -XX:+CMSParallelRemarkEnabled \
    -XX:+DisableExplicitGC \
    -XX:+HeapDumpOnOutOfMemoryError \
    -XX:+ResizeTLAB \
    -XX:+UseCMSInitiatingOccupancyOnly \
    -XX:+UseCompressedOops \
    -XX:+UseConcMarkSweepGC \
    -XX:+UseFastAccessorMethods \
    -XX:+UseParNewGC \
    -XX:CMSInitiatingOccupancyFraction=75 \
    -XX:NewRatio=1 \
    "

app_pidfile="${graylog_run_dir}/${name}.pid"
pidfile="${graylog_run_dir}/daemon.pid"
command="/usr/sbin/daemon"

command_args=" \
    -c \
    -t ${name} \
    -r \
    -p ${app_pidfile} \
    -P ${pidfile} \
    %%LOCALBASE%%/bin/java \
    ${java_options} \
    -jar ${graylog_dir}/graylog.jar server \
    --no-pid-file \
    --configfile ${graylog_config}"

required_files="%%LOCALBASE%%/bin/java ${graylog_config}"

graylog_precmd() {
    install -d -o ${graylog_user} -g ${graylog_group} -m 750 "${graylog_data_dir}"
    install -d -o ${graylog_user} -g ${graylog_group} -m 750 "${graylog_logs_dir}"
    install -d -o ${graylog_user} -g ${graylog_group} -m 750 "${graylog_run_dir}"
}

start_precmd="graylog_precmd"

run_rc_command "$1"