| 1 |
From: Michael Fladischer <[email protected]> |
| 2 |
Date: Thu, 8 Oct 2015 08:37:02 -0700 |
| 3 |
Subject: LSB compliant headers, status actions and ENABLED variable |
| 4 |
|
| 5 |
Upstream ships it's own init scripts but they lack some LSB header and |
| 6 |
the (optional) "status" action. This patch fixes this and also adds a |
| 7 |
variable called ENABLED in /etc/default/celeryd. |
| 8 |
Last-Update: 2013-09-03 |
| 9 |
Forwarded: no |
| 10 |
|
| 11 |
Patch-Name: lsb-init.patch |
| 12 |
--- |
| 13 |
extra/generic-init.d/celerybeat | 13 +++++++++++++ |
| 14 |
extra/generic-init.d/celeryd | 11 +++++++++++ |
| 15 |
2 files changed, 24 insertions(+) |
| 16 |
|
| 17 |
diff --git a/extra/generic-init.d/celerybeat b/extra/generic-init.d/celerybeat |
| 18 |
index b554844..b34eb25 100755 |
| 19 |
--- a/extra/generic-init.d/celerybeat |
| 20 |
+++ b/extra/generic-init.d/celerybeat |
| 21 |
@@ -15,11 +15,15 @@ |
| 22 |
# Default-Start: 2 3 4 5 |
| 23 |
# Default-Stop: 0 1 6 |
| 24 |
# Short-Description: celery periodic task scheduler |
| 25 |
+# Description: Controls the Celery periodic task scheduler. |
| 26 |
### END INIT INFO |
| 27 |
|
| 28 |
# Cannot use set -e/bash -e since the kill -0 command will abort |
| 29 |
# abnormally in the absence of a valid process ID. |
| 30 |
#set -e |
| 31 |
+ |
| 32 |
+. /lib/lsb/init-functions |
| 33 |
+ |
| 34 |
VERSION=10.1 |
| 35 |
echo "celery init v${VERSION}." |
| 36 |
|
| 37 |
@@ -90,6 +94,7 @@ _config_sanity() { |
| 38 |
|
| 39 |
scripts="" |
| 40 |
|
| 41 |
+ |
| 42 |
if test -f /etc/default/celeryd; then |
| 43 |
scripts="/etc/default/celeryd" |
| 44 |
_config_sanity /etc/default/celeryd |
| 45 |
@@ -118,6 +123,14 @@ CELERYBEAT_LOG_LEVEL=${CELERYBEAT_LOG_LEVEL:-${CELERYBEAT_LOGLEVEL:-$DEFAULT_LOG |
| 46 |
CELERYBEAT_SU=${CELERYBEAT_SU:-"su"} |
| 47 |
CELERYBEAT_SU_ARGS=${CELERYBEAT_SU_ARGS:-""} |
| 48 |
|
| 49 |
+DEFAULT_ENABLED="false" |
| 50 |
+ |
| 51 |
+ENABLED=${ENABLED:-$DEFAULT_ENABLED} |
| 52 |
+if [ "$ENABLED" != "true" ]; then |
| 53 |
+ echo "celerybeat daemon disabled - see $scripts." |
| 54 |
+ exit 0 |
| 55 |
+fi |
| 56 |
+ |
| 57 |
# Sets --app argument for CELERY_BIN |
| 58 |
CELERY_APP_ARG="" |
| 59 |
if [ ! -z "$CELERY_APP" ]; then |
| 60 |
diff --git a/extra/generic-init.d/celeryd b/extra/generic-init.d/celeryd |
| 61 |
index 13fddde..2ef11fd 100755 |
| 62 |
--- a/extra/generic-init.d/celeryd |
| 63 |
+++ b/extra/generic-init.d/celeryd |
| 64 |
@@ -16,6 +16,7 @@ |
| 65 |
# Default-Start: 2 3 4 5 |
| 66 |
# Default-Stop: 0 1 6 |
| 67 |
# Short-Description: celery task worker daemon |
| 68 |
+# Description: Controls a celery task worker daemon instance |
| 69 |
### END INIT INFO |
| 70 |
# |
| 71 |
# |
| 72 |
@@ -27,6 +28,9 @@ |
| 73 |
# |
| 74 |
# You can then configure this by manipulating /etc/default/little-worker. |
| 75 |
# |
| 76 |
+ |
| 77 |
+. /lib/lsb/init-functions |
| 78 |
+ |
| 79 |
VERSION=10.1 |
| 80 |
echo "celery init v${VERSION}." |
| 81 |
if [ $(id -u) -ne 0 ]; then |
| 82 |
@@ -56,6 +60,7 @@ DEFAULT_LOG_FILE="/var/log/celery/%n%I.log" |
| 83 |
DEFAULT_LOG_LEVEL="INFO" |
| 84 |
DEFAULT_NODES="celery" |
| 85 |
DEFAULT_CELERYD="-m celery worker --detach" |
| 86 |
+DEFAULT_ENABLED="false" |
| 87 |
|
| 88 |
if [ -d "/etc/default" ]; then |
| 89 |
CELERY_CONFIG_DIR="/etc/default" |
| 90 |
@@ -114,6 +119,12 @@ if [ -f "$CELERY_DEFAULTS" ]; then |
| 91 |
. "$CELERY_DEFAULTS" |
| 92 |
fi |
| 93 |
|
| 94 |
+ENABLED=${ENABLED:-$DEFAULT_ENABLED} |
| 95 |
+if [ "$ENABLED" != "true" ]; then |
| 96 |
+ echo "celery daemon disabled - see $CELERY_DEFAULTS" |
| 97 |
+ exit 0 |
| 98 |
+fi |
| 99 |
+ |
| 100 |
# Sets --app argument for CELERY_BIN |
| 101 |
CELERY_APP_ARG="" |
| 102 |
if [ ! -z "$CELERY_APP" ]; then |