blob: 5d59c21f7f87bfae24c92418db3bc7114bc27180 (
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
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
|
#!/bin/sh
# PROVIDE: couchdb3
# REQUIRE: LOGIN
# KEYWORD: shutdown
#
# Add the following lines to /etc/rc.conf.local or /etc/rc.conf
# to enable this service:
#
# couchdb3_enable (bool): Set to NO by default.
# Set it to YES to enable couchdb.
. /etc/rc.subr
name=%%PORTNAME%%
rcvar=%%PORTNAME%%_enable
start_cmd="${name}_start"
stop_cmd="${name}_stop"
status_cmd="${name}_status"
load_rc_config $name
: ${%%PORTNAME%%_enable:="NO"}
: ${%%PORTNAME%%_user="couchdb"}
: ${%%PORTNAME%%_erl_flags="-couch_ini %%APPDIR%%/etc/default.ini %%ETCDIR%%/local.ini"}
: ${%%PORTNAME%%_chdir="/var/db/%%PORTNAME%%"}
command="%%ERL_PATH%%"
pidfile="/var/run/${name}.pid"
daemonpidfile="/var/run/${name}-daemon.pid"
erl_sasl='-sasl releases_dir \"%%PORTNAME%%/releases\"'
erl_boot='-boot %%RELDIR%%/couchdb -boot_var RELTOOL_EXT_LIB %%APPDIR%%/lib'
erl_args='-args_file %%ETCDIR%%/vm.args'
erl_flags="${erl_sasl} ${erl_boot} ${erl_args} ${%%PORTNAME%%_erl_flags}"
%%PORTNAME%%_start()
{
# chdir manually as overriding _start() blocks rc.subr defaults
cd "${%%PORTNAME%%_chdir}"
/usr/sbin/daemon -p ${pidfile} \
-P ${daemonpidfile} \
-t ${name} \
-u ${%%PORTNAME%%_user} \
env ERL_FLAGS="${erl_flags}" \
HOME=/var/run/couchdb \
ERL_CRASH_DUMP=/var/run/couchdb/erl_crash.dump \
COUCHDB_FAUXTON_DOCROOT=%%WWWDIR%% \
COUCHDB_QUERY_SERVER_JAVASCRIPT="%%APPDIR%%/bin/couchjs %%APPDIR%%/share/server/main.js" \
COUCHDB_QUERY_SERVER_COFFEESCRIPT="%%APPDIR%%/bin/couchjs %%APPDIR%%/share/server/main-coffee.js" \
${command}
}
%%PORTNAME%%_stop()
{
echo -n "Stopping ${name}: "
retval=0
if ! status_quiet
then
echo "already stopped"
return 1
else
%%PORTNAME%%_pids=$(/bin/pgrep -ifU ${%%PORTNAME%%_user} ${name})
kill ${%%PORTNAME%%_pids}
wait_for_pids ${%%PORTNAME%%_pids}
retval=$?
echo "stopped"
fi
return $retval
}
%%PORTNAME%%_status()
{
/bin/pgrep -ifU ${%%PORTNAME%%_user} ${name} > /dev/null && status="$?" || status="$?"
if [ "${status}" = 0 ]; then
echo "${name} is running"
return 0
elif [ "${status}" = 4 ]; then
echo "could not access PID file for ${name}"
return ${status}
else
echo "${name} is not running"
return ${status}
fi
}
status_quiet()
{
%%PORTNAME%%_status >/dev/null 2>&1
}
run_rc_command $1
|