Package: celery / 2.5.3-4

lsb-init.patch Patch series | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
Description: 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.
Author: Michael Fladischer <FladischerMichael@fladi.at>
Last-Update: 2012-01-18
Forwarded: no

--- a/contrib/generic-init.d/celeryd
+++ b/contrib/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:       Starts the Celery worker daemon for a single project.
 ### END INIT INFO
 
 #set -e
@@ -25,16 +26,18 @@
 DEFAULT_LOG_LEVEL="INFO"
 DEFAULT_NODES="celery"
 DEFAULT_CELERYD="-m celery.bin.celeryd_detach"
+ENABLED="false"
 
-# /etc/init.d/celeryd: start and stop the celery task worker daemon.
+[ -r "$CELERY_DEFAULTS" ] && . "$CELERY_DEFAULTS"
 
-CELERY_DEFAULTS=${CELERY_DEFAULTS:-"/etc/default/celeryd"}
+[ -r /etc/default/celeryd ] && . /etc/default/celeryd
 
-test -f "$CELERY_DEFAULTS" && . "$CELERY_DEFAULTS"
-if [ -f "/etc/default/celeryd" ]; then
-    . /etc/default/celeryd
+if [ "$ENABLED" != "true" ]; then
+    echo "celery daemon disabled - see /etc/default/celeryd."
+    exit 0
 fi
 
+
 CELERYD_PID_FILE=${CELERYD_PID_FILE:-${CELERYD_PIDFILE:-$DEFAULT_PID_FILE}}
 CELERYD_LOG_FILE=${CELERYD_LOG_FILE:-${CELERYD_LOGFILE:-$DEFAULT_LOG_FILE}}
 CELERYD_LOG_LEVEL=${CELERYD_LOG_LEVEL:-${CELERYD_LOGLEVEL:-$DEFAULT_LOG_LEVEL}}
--- a/contrib/generic-init.d/celeryevcam
+++ b/contrib/generic-init.d/celeryevcam
@@ -1,6 +1,6 @@
 #!/bin/bash
 # ============================================
-#  celeryd - Starts the Celery worker daemon.
+#  celeryevcam - Starts the Celery event snapshot daemon.
 # ============================================
 #
 # :Usage: /etc/init.d/celeryd {start|stop|force-reload|restart|try-restart|status}
@@ -78,12 +78,13 @@
 #       Full path to the virtualenv environment to activate. Default is none.
 
 ### BEGIN INIT INFO
-# Provides:          celeryev
+# Provides:          celeryevcam
 # Required-Start:    $network $local_fs $remote_fs
 # Required-Stop:     $network $local_fs $remote_fs
 # Default-Start:     2 3 4 5
 # Default-Stop:      0 1 6
 # Short-Description: celery event snapshots
+# Description:       Starts the Celery event snapshots daemon for a single project.
 ### END INIT INFO
 
 # Cannot use set -e/bash -e since the kill -0 command will abort
@@ -94,13 +95,15 @@
 DEFAULT_LOG_FILE="/var/log/celeryev.log"
 DEFAULT_LOG_LEVEL="INFO"
 DEFAULT_CELERYEV="/usr/bin/celeryev"
+ENABLED="false"
 
-if test -f /etc/default/celeryd; then
-    . /etc/default/celeryd
-fi
+[ -r /etc/default/celeryd ] && . /etc/default/celeryd
+
+[ -r /etc/default/celeryev ] && . /etc/default/celeryev
 
-if test -f /etc/default/celeryev; then
-    . /etc/default/celeryev
+if [ "$ENABLED" != "true" ]; then
+    echo "celeryevcam daemon disabled - see /etc/default/celeryd."
+    exit 0
 fi
 
 CELERYEV=${CELERYEV:-$DEFAULT_CELERYEV}
@@ -197,7 +200,16 @@
               --pidfile="$CELERYEV_PID_FILE"
 }
 
-
+status () {
+    pid=$(cat "$CELERYEV_PID_FILE")
+    kill -0 $pid 1>/dev/null 2>&1
+    if [ $? -eq 0 ]; then
+        echo "celeryevcam running"
+    else
+        echo "celeryevcam not running"
+        exit 1
+    fi
+}
 
 case "$1" in
   start)
@@ -216,9 +228,12 @@
     check_dev_null
     start_evcam
     ;;
+  status)
+    status
+    ;;
 
   *)
-    echo "Usage: /etc/init.d/celeryev {start|stop|restart}"
+    echo "Usage: /etc/init.d/celeryev {start|stop|restart|status}"
     exit 1
 esac
 
--- a/contrib/generic-init.d/celerybeat
+++ b/contrib/generic-init.d/celerybeat
@@ -15,6 +15,7 @@
 # Default-Start:     2 3 4 5
 # Default-Stop:      0 1 6
 # Short-Description: celery periodic task scheduler
+# Description:       Starts the Celery periodic task scheduler.
 ### END INIT INFO
 
 # Cannot use set -e/bash -e since the kill -0 command will abort
@@ -25,15 +26,15 @@
 DEFAULT_LOG_FILE="/var/log/celerybeat.log"
 DEFAULT_LOG_LEVEL="INFO"
 DEFAULT_CELERYBEAT="celerybeat"
+ENABLED="false"
 
-# /etc/init.d/ssh: start and stop the celery task worker daemon.
+[ -r /etc/default/celeryd ] && . /etc/default/celeryd
 
-if test -f /etc/default/celeryd; then
-    . /etc/default/celeryd
-fi
+[ -r /etc/default/celerybeat ] && . /etc/default/celerybeat
 
-if test -f /etc/default/celerybeat; then
-    . /etc/default/celerybeat
+if [ "$ENABLED" != "true" ]; then
+    echo "celerybeat daemon disabled - read /etc/default/celeryd."
+    exit 0
 fi
 
 CELERYBEAT=${CELERYBEAT:-$DEFAULT_CELERYBEAT}
@@ -125,7 +126,16 @@
                 --pidfile="$CELERYBEAT_PID_FILE"
 }
 
-
+status () {
+    pid=$(cat "$CELERYBEAT_PID_FILE")
+    kill -0 $pid 1>/dev/null 2>&1
+    if [ $? -eq 0 ]; then
+        echo "celerybeat running"
+    else
+        echo "celerybeat not running"
+        exit 1
+    fi
+}
 
 case "$1" in
   start)
@@ -144,9 +154,12 @@
     check_dev_null
     start_beat
     ;;
+  status)
+    status
+    ;;
 
   *)
-    echo "Usage: /etc/init.d/celerybeat {start|stop|restart}"
+    echo "Usage: /etc/init.d/celerybeat {start|stop|restart|status}"
     exit 1
 esac