Files
vrobbler/rc.d/vrobbler_celery_priority

46 lines
1.7 KiB
Bash
Executable File

#!/bin/sh
#
# rc.d script for the vrobbler high-priority Celery worker.
#
# PROVIDE: vrobbler_celery_priority
# REQUIRE: NETWORKING postgresql redis
# KEYWORD: shutdown
#
# Installation (on the FreeBSD jail):
#
# install -m 0555 rc.d/vrobbler_celery_priority /usr/local/etc/rc.d/vrobbler_celery_priority
# sysrc vrobbler_celery_priority_enable="YES"
# service vrobbler_celery_priority start
#
# Configuration (via sysrc or /etc/rc.conf):
#
# vrobbler_celery_priority_queues - queues to consume (default: priority)
# vrobbler_celery_priority_bin - path to celery (default: /usr/local/bin/celery)
# vrobbler_celery_priority_flags - extra daemon(8) flags
#
# Consumes the "priority" queue where interactive/user-facing tasks (agent
# session prompts, Mopidy queue adds, favorites, reverse geocoding) are routed.
# Higher concurrency with a small prefetch keeps these tasks snappy even when
# the default and background workers are busy. The nodename is fixed to
# priority@<hostname> so it can coexist with the other workers on one host.
#
. /etc/rc.subr
name="vrobbler_celery_priority"
rcvar="vrobbler_celery_priority_enable"
load_rc_config ${name}
: ${vrobbler_celery_priority_enable:="NO"}
: ${vrobbler_celery_priority_queues:="priority"}
: ${vrobbler_celery_priority_bin:="/usr/local/bin/celery"}
: ${vrobbler_celery_priority_concurrency:="4"}
: ${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_priority_bin} -A vrobbler worker -Q ${vrobbler_celery_priority_queues} -n priority@%h --concurrency=${vrobbler_celery_priority_concurrency} --prefetch-multiplier=1 -l info --logfile ${vrobbler_log_dir}/${name}.log"
run_rc_command "$1"