summaryrefslogtreecommitdiff
path: root/sysutils/alloy/files/alloy.in
blob: 68ddee8322ca96c23901cce68fb774c71c1067b0 (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
#!/bin/sh

# PROVIDE: alloy
# REQUIRE: LOGIN
# KEYWORD: shutdown
#
# Add the following lines to /etc/rc.conf.local or /etc/rc.conf
# to enable this service:
#
# alloy_enable (bool):          Set to NO by default.
#               Set it to YES to enable alloy.
# alloy_user (string):          Set user that alloy will run under
#               Default is "nobody".
# alloy_group (string):         Set group that alloy will run under
#               Default is "nobody".
# alloy_listen_address (string):Set ip:port that alloy will listen on
#               Default is ":9200".
# alloy_storage_path (string):  Set storage.path
#               Default is "/var/alloy".
# alloy_args (string):          Set extra arguments to pass to alloy
#               Default is "".

. /etc/rc.subr

name=alloy
rcvar=alloy_enable

load_rc_config $name

: ${alloy_enable:="NO"}
: ${alloy_user:="nobody"}
: ${alloy_group:="nobody"}
: ${alloy_args:=""}
: ${alloy_storage_path:="/var/alloy"}
: ${alloy_listen_address:=":9200"}

pidfile=/var/run/alloy.pid
command="/usr/sbin/daemon"
procname="%%PREFIX%%/bin/alloy"
run="run /usr/local/etc/alloy.flow"
command_args="-S -T ${name} -p ${pidfile} /usr/bin/env ${procname} ${run} \
    --storage.path=${alloy_storage_path} --server.http.listen-addr=${alloy_listen_address} ${alloy_args}"

start_precmd=alloy_startprecmd

alloy_startprecmd() {
  if [ ! -e ${pidfile} ]; then
    install -o ${alloy_user} -g ${alloy_group} /dev/null ${pidfile}
  fi
}

load_rc_config $name
run_rc_command "$1"