From: Michael Fladischer Date: Thu, 8 Oct 2015 08:37:02 -0700 Subject: LSB compliant headers, status actions and ENABLED variable Upstream ships it's own init scripts but they lack some LSB header and the (optional) "status" action. This patch fixes this and also adds a variable called ENABLED in /etc/default/celeryd. Last-Update: 2013-09-03 Forwarded: no Patch-Name: lsb-init.patch --- extra/generic-init.d/celerybeat | 13 +++++++++++++ extra/generic-init.d/celeryd | 11 +++++++++++ 2 files changed, 24 insertions(+) diff --git a/extra/generic-init.d/celerybeat b/extra/generic-init.d/celerybeat index b554844..b34eb25 100755 --- a/extra/generic-init.d/celerybeat +++ b/extra/generic-init.d/celerybeat @@ -15,11 +15,15 @@ # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: celery periodic task scheduler +# Description: Controls the Celery periodic task scheduler. ### END INIT INFO # Cannot use set -e/bash -e since the kill -0 command will abort # abnormally in the absence of a valid process ID. #set -e + +. /lib/lsb/init-functions + VERSION=10.1 echo "celery init v${VERSION}." @@ -90,6 +94,7 @@ _config_sanity() { scripts="" + if test -f /etc/default/celeryd; then scripts="/etc/default/celeryd" _config_sanity /etc/default/celeryd @@ -118,6 +123,14 @@ CELERYBEAT_LOG_LEVEL=${CELERYBEAT_LOG_LEVEL:-${CELERYBEAT_LOGLEVEL:-$DEFAULT_LOG CELERYBEAT_SU=${CELERYBEAT_SU:-"su"} CELERYBEAT_SU_ARGS=${CELERYBEAT_SU_ARGS:-""} +DEFAULT_ENABLED="false" + +ENABLED=${ENABLED:-$DEFAULT_ENABLED} +if [ "$ENABLED" != "true" ]; then + echo "celerybeat daemon disabled - see $scripts." + exit 0 +fi + # Sets --app argument for CELERY_BIN CELERY_APP_ARG="" if [ ! -z "$CELERY_APP" ]; then diff --git a/extra/generic-init.d/celeryd b/extra/generic-init.d/celeryd index 13fddde..2ef11fd 100755 --- a/extra/generic-init.d/celeryd +++ b/extra/generic-init.d/celeryd @@ -16,6 +16,7 @@ # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: celery task worker daemon +# Description: Controls a celery task worker daemon instance ### END INIT INFO # # @@ -27,6 +28,9 @@ # # You can then configure this by manipulating /etc/default/little-worker. # + +. /lib/lsb/init-functions + VERSION=10.1 echo "celery init v${VERSION}." if [ $(id -u) -ne 0 ]; then @@ -56,6 +60,7 @@ DEFAULT_LOG_FILE="/var/log/celery/%n%I.log" DEFAULT_LOG_LEVEL="INFO" DEFAULT_NODES="celery" DEFAULT_CELERYD="-m celery worker --detach" +DEFAULT_ENABLED="false" if [ -d "/etc/default" ]; then CELERY_CONFIG_DIR="/etc/default" @@ -114,6 +119,12 @@ if [ -f "$CELERY_DEFAULTS" ]; then . "$CELERY_DEFAULTS" fi +ENABLED=${ENABLED:-$DEFAULT_ENABLED} +if [ "$ENABLED" != "true" ]; then + echo "celery daemon disabled - see $CELERY_DEFAULTS" + exit 0 +fi + # Sets --app argument for CELERY_BIN CELERY_APP_ARG="" if [ ! -z "$CELERY_APP" ]; then