55 lines
1.9 KiB
Bash
Executable File
55 lines
1.9 KiB
Bash
Executable File
#!/bin/sh
|
|
#
|
|
# rc.d script for the vrobbler Celery worker.
|
|
#
|
|
# PROVIDE: vrobbler_celery
|
|
# REQUIRE: NETWORKING postgresql redis
|
|
# KEYWORD: shutdown
|
|
#
|
|
# Installation (on the FreeBSD jail):
|
|
#
|
|
# install -m 0555 rc.d/vrobbler_celery /usr/local/etc/rc.d/vrobbler_celery
|
|
# sysrc vrobbler_celery_enable="YES"
|
|
# service vrobbler_celery start
|
|
#
|
|
# Configuration (via sysrc or /etc/rc.conf):
|
|
#
|
|
# vrobbler_celery_queues - queues to consume (default: default,charts)
|
|
# vrobbler_celery_bin - path to celery (default: /usr/local/bin/celery)
|
|
# vrobbler_celery_user - user to run as (default: root)
|
|
# vrobbler_celery_flags - extra daemon(8) flags
|
|
#
|
|
# NOTE: do not name the celery path knob "${name}_program". FreeBSD's
|
|
# rc.subr(8) overrides $command with ${name}_program whenever it is set,
|
|
# which would replace the daemon(8) wrapper with celery itself.
|
|
#
|
|
# The command is run under daemon(8) with a supervisor pidfile (-P) and
|
|
# restart-on-crash (-R), so the worker is automatically restarted if it dies,
|
|
# in the same way immortal used to. Sending SIGTERM to the supervisor (which
|
|
# is what `service vrobbler_celery stop` does) forwards the signal to celery,
|
|
# which shuts the worker down gracefully.
|
|
#
|
|
# The queues match the old immortal/Procfile setup. If you ever run more than
|
|
# one worker instance, give each a unique nodename via -n (celery@%h is the
|
|
# hostname default).
|
|
#
|
|
. /etc/rc.subr
|
|
|
|
name="vrobbler_celery"
|
|
rcvar="vrobbler_celery_enable"
|
|
|
|
load_rc_config ${name}
|
|
|
|
: ${vrobbler_celery_enable:="NO"}
|
|
: ${vrobbler_celery_queues:="default,charts"}
|
|
: ${vrobbler_celery_bin:="/usr/local/bin/celery"}
|
|
: ${vrobbler_celery_autoscale:="2,6"}
|
|
: ${vrobbler_log_dir:="/var/log"}
|
|
|
|
pidfile="/var/run/${name}.pid"
|
|
|
|
command="/usr/sbin/daemon"
|
|
command_args="-f -P ${pidfile} -R 5 -t ${name} ${vrobbler_celery_bin} -A vrobbler worker -Q ${vrobbler_celery_queues} -n celery@%h -l info --logfile ${vrobbler_log_dir}/${name}.log"
|
|
|
|
run_rc_command "$1"
|