#!/bin/sh # # rc.d script for the vrobbler background Celery worker. # # PROVIDE: vrobbler_celery_background # REQUIRE: NETWORKING postgresql redis # KEYWORD: shutdown # # Installation (on the FreeBSD jail): # # install -m 0555 rc.d/vrobbler_celery_background /usr/local/etc/rc.d/vrobbler_celery_background # sysrc vrobbler_celery_background_enable="YES" # service vrobbler_celery_background start # # Configuration (via sysrc or /etc/rc.conf): # # vrobbler_celery_background_queues - queues to consume (default: background) # vrobbler_celery_background_bin - path to celery (default: /usr/local/bin/celery) # vrobbler_celery_background_flags - extra daemon(8) flags # # Consumes the "background" queue where heavy, scheduled off-peak jobs are # routed (database backups, trend computation, sentiment backfill, chart # rebuilds, historical imports). Low concurrency keeps these CPU/I/O heavy jobs # from starving the other workers. The nodename is fixed to # background@ so it can coexist with the other workers on one host. # . /etc/rc.subr name="vrobbler_celery_background" rcvar="vrobbler_celery_background_enable" load_rc_config ${name} : ${vrobbler_celery_background_enable:="NO"} : ${vrobbler_celery_background_queues:="background"} : ${vrobbler_celery_background_bin:="/usr/local/bin/celery"} : ${vrobbler_celery_background_concurrency:="1"} : ${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_background_bin} -A vrobbler worker -Q ${vrobbler_celery_background_queues} -n background@%h --concurrency=${vrobbler_celery_background_concurrency} -l info --logfile ${vrobbler_log_dir}/${name}.log" run_rc_command "$1"