aboutsummaryrefslogtreecommitdiff
path: root/databases/clickhouse/files/clickhouse.in
blob: 7fa89c7129d50bffe7909bbdc7fb4e9e01d51b3d (plain) (blame)
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
#!/bin/sh

# $FreeBSD$
#
# PROVIDE: clickhouse
# REQUIRE: LOGIN
# KEYWORD: shutdown
#
# Add the following line to /etc/rc.conf[.local] to enable clickhouse server
#
# clickhouse_enable (bool):  Set to "NO" by default
#                          Set it to "YES" to enable clickhouse server
# clickhouse_limits (bool):  Set to "NO" by default.
#                        Set it to yes to run `limits -e -U clickhouse`
#                        just before clickhouse starts.
# clickhouse_config (str): Path to config file (required).
#                          (default: %%PREFIX%%/etc/clickhouse-server/config.xml)
# clickhouse_rundir (str):   Path to directory holding a pidfile.
#                          (default: /var/run/clickhouse)
# clickhouse_user (str):     User to run as
#                          (default: clickhouse)
# clickhouse_group (str):    Group to run as
#                          (default: clickhouse)
# clickhouse_logdir (str):   Path to log directory
#                          (default: /var/log/clickhouse)
# clickhouse_dbdir (str):    Path to world database directory
#                          (default: /var/db/clickhouse)

. /etc/rc.subr

name=clickhouse
rcvar=clickhouse_enable

load_rc_config ${name}

: ${clickhouse_enable="NO"}
: ${clickhouse_limits="NO"}
: ${clickhouse_config="%%PREFIX%%/etc/clickhouse-server/config.xml"}
: ${clickhouse_rundir="/var/run/clickhouse"}
: ${clickhouse_user="clickhouse"}
: ${clickhouse_group="clickhouse"}
: ${clickhouse_logdir="/var/log/clickhouse"}
: ${clickhouse_dbdir="/var/db/clickhouse"}
: ${clickhouse_flags=""}
: ${clickhouse_args="--server --config-file ${clickhouse_config} ${clickhouse_flags}"}

command=/usr/sbin/daemon
procname=/usr/local/bin/clickhouse
pidfile=${clickhouse_rundir}/clickhouse.pid
command_args="-c -f -p ${pidfile} ${procname} ${clickhouse_args}"
required_files=${clickhouse_config}
start_precmd=clickhouse_prestart

clickhouse_prestart () {
	if checkyesno clickhouse_limits; then
		eval `/usr/bin/limits -e -U ${clickhouse_user}` 2>/dev/null
	else
		return 0
	fi
}

run_rc_command "$1"