Show More
@@ -0,0 +1,224 b'' | |||
|
1 | #!/bin/sh -e | |
|
2 | # ============================================ | |
|
3 | # celeryd - Starts the Celery worker daemon. | |
|
4 | # ============================================ | |
|
5 | # | |
|
6 | # :Usage: /etc/init.d/celeryd {start|stop|force-reload|restart|try-restart|status} | |
|
7 | # | |
|
8 | # :Configuration file: /etc/default/celeryd | |
|
9 | # | |
|
10 | # To configure celeryd you probably need to tell it where to chdir. | |
|
11 | # | |
|
12 | # EXAMPLE CONFIGURATION | |
|
13 | # ===================== | |
|
14 | # | |
|
15 | # this is an example configuration for a Python project: | |
|
16 | # | |
|
17 | # /etc/default/celeryd: | |
|
18 | # | |
|
19 | # # Where to chdir at start. | |
|
20 | # CELERYD_CHDIR="/opt/Myproject/" | |
|
21 | # | |
|
22 | # # Extra arguments to celeryd | |
|
23 | # CELERYD_OPTS="--time-limit 300" | |
|
24 | # | |
|
25 | # # Name of the celery config module.# | |
|
26 | # CELERY_CONFIG_MODULE="celeryconfig" | |
|
27 | # | |
|
28 | # EXAMPLE DJANGO CONFIGURATION | |
|
29 | # ============================ | |
|
30 | # | |
|
31 | # # Where the Django project is. | |
|
32 | # CELERYD_CHDIR="/opt/Project/" | |
|
33 | # | |
|
34 | # # Name of the projects settings module. | |
|
35 | # DJANGO_SETTINGS_MODULE="settings" | |
|
36 | # | |
|
37 | # # Path to celeryd | |
|
38 | # CELERYD="/opt/Project/manage.py celeryd" | |
|
39 | # | |
|
40 | # AVAILABLE OPTIONS | |
|
41 | # ================= | |
|
42 | # | |
|
43 | # * CELERYD_OPTS | |
|
44 | # Additional arguments to celeryd, see ``celeryd --help`` for a list. | |
|
45 | # | |
|
46 | # * CELERYD_CHDIR | |
|
47 | # Path to chdir at start. Default is to stay in the current directory. | |
|
48 | # | |
|
49 | # * CELERYD_PIDFILE | |
|
50 | # Full path to the pidfile. Default is /var/run/celeryd.pid. | |
|
51 | # | |
|
52 | # * CELERYD_LOGFILE | |
|
53 | # Full path to the celeryd logfile. Default is /var/log/celeryd.log | |
|
54 | # | |
|
55 | # * CELERYD_LOG_LEVEL | |
|
56 | # Log level to use for celeryd. Default is INFO. | |
|
57 | # | |
|
58 | # * CELERYD | |
|
59 | # Path to the celeryd program. Default is ``celeryd``. | |
|
60 | # You can point this to an virtualenv, or even use manage.py for django. | |
|
61 | # | |
|
62 | # * CELERYD_USER | |
|
63 | # User to run celeryd as. Default is current user. | |
|
64 | # | |
|
65 | # * CELERYD_GROUP | |
|
66 | # Group to run celeryd as. Default is current user. | |
|
67 | ||
|
68 | ||
|
69 | ### BEGIN INIT INFO | |
|
70 | # Provides: celeryd | |
|
71 | # Required-Start: $network $local_fs $remote_fs | |
|
72 | # Required-Stop: $network $local_fs $remote_fs | |
|
73 | # Default-Start: 2 3 4 5 | |
|
74 | # Default-Stop: 0 1 6 | |
|
75 | # Short-Description: celery task worker daemon | |
|
76 | ### END INIT INFO | |
|
77 | ||
|
78 | set -e | |
|
79 | CELERYD_CHDIR="/opt/Myproject/" | |
|
80 | CELERYD_PID_FILE="/var/run/celeryd.pid" | |
|
81 | CELERYD_LOG_FILE="/var/log/celeryd.log" | |
|
82 | CELERYD_LOG_LEVEL="DEBUG" | |
|
83 | DEFAULT_CELERYD="/home/v-env/celeryd" | |
|
84 | ||
|
85 | # /etc/init.d/ssh: start and stop the celery task worker daemon. | |
|
86 | ||
|
87 | if test -f /etc/default/celeryd; then | |
|
88 | . /etc/default/celeryd | |
|
89 | fi | |
|
90 | ||
|
91 | CELERYD=${CELERYD:-$DEFAULT_CELERYD} | |
|
92 | ||
|
93 | export CELERY_LOADER | |
|
94 | ||
|
95 | . /lib/lsb/init-functions | |
|
96 | ||
|
97 | CELERYD_OPTS="$CELERYD_OPTS -f $CELERYD_LOG_FILE -l $CELERYD_LOG_LEVEL" | |
|
98 | ||
|
99 | if [ -n "$2" ]; then | |
|
100 | CELERYD_OPTS="$CELERYD_OPTS $2" | |
|
101 | fi | |
|
102 | ||
|
103 | # Extra start-stop-daemon options, like user/group. | |
|
104 | if [ -n "$CELERYD_USER" ]; then | |
|
105 | DAEMON_OPTS="$DAEMON_OPTS --chuid $CELERYD_USER" | |
|
106 | fi | |
|
107 | if [ -n "$CELERYD_GROUP" ]; then | |
|
108 | DAEMON_OPTS="$DAEMON_OPTS --group $CELERYD_GROUP" | |
|
109 | fi | |
|
110 | ||
|
111 | if [ -n "$CELERYD_CHDIR" ]; then | |
|
112 | DAEMON_OPTS="$DAEMON_OPTS --chdir $CELERYD_CHDIR" | |
|
113 | fi | |
|
114 | ||
|
115 | ||
|
116 | # Are we running from init? | |
|
117 | run_by_init() { | |
|
118 | ([ "$previous" ] && [ "$runlevel" ]) || [ "$runlevel" = S ] | |
|
119 | } | |
|
120 | ||
|
121 | ||
|
122 | check_dev_null() { | |
|
123 | if [ ! -c /dev/null ]; then | |
|
124 | if [ "$1" = log_end_msg ]; then | |
|
125 | log_end_msg 1 || true | |
|
126 | fi | |
|
127 | if ! run_by_init; then | |
|
128 | log_action_msg "/dev/null is not a character device!" | |
|
129 | fi | |
|
130 | exit 1 | |
|
131 | fi | |
|
132 | } | |
|
133 | ||
|
134 | ||
|
135 | export PATH="${PATH:+$PATH:}/usr/sbin:/sbin" | |
|
136 | ||
|
137 | ||
|
138 | stop_worker () { | |
|
139 | cmd="start-stop-daemon --stop \ | |
|
140 | --quiet \ | |
|
141 | $* \ | |
|
142 | --pidfile $CELERYD_PID_FILE" | |
|
143 | if $cmd; then | |
|
144 | log_end_msg 0 | |
|
145 | else | |
|
146 | log_end_msg 1 | |
|
147 | fi | |
|
148 | } | |
|
149 | ||
|
150 | start_worker () { | |
|
151 | cmd="start-stop-daemon --start $DAEMON_OPTS \ | |
|
152 | --quiet \ | |
|
153 | --oknodo \ | |
|
154 | --background \ | |
|
155 | --make-pidfile \ | |
|
156 | $* \ | |
|
157 | --pidfile $CELERYD_PID_FILE | |
|
158 | --exec $CELERYD -- $CELERYD_OPTS" | |
|
159 | if $cmd; then | |
|
160 | log_end_msg 0 | |
|
161 | else | |
|
162 | log_end_msg 1 | |
|
163 | fi | |
|
164 | } | |
|
165 | ||
|
166 | ||
|
167 | ||
|
168 | case "$1" in | |
|
169 | start) | |
|
170 | check_dev_null | |
|
171 | log_daemon_msg "Starting celery task worker server" "celeryd" | |
|
172 | start_worker | |
|
173 | ;; | |
|
174 | stop) | |
|
175 | log_daemon_msg "Stopping celery task worker server" "celeryd" | |
|
176 | stop_worker --oknodo | |
|
177 | ;; | |
|
178 | ||
|
179 | reload|force-reload) | |
|
180 | echo "Use start+stop" | |
|
181 | ;; | |
|
182 | ||
|
183 | restart) | |
|
184 | log_daemon_msg "Restarting celery task worker server" "celeryd" | |
|
185 | stop_worker --oknodo --retry 30 | |
|
186 | check_dev_null log_end_msg | |
|
187 | start_worker | |
|
188 | ;; | |
|
189 | ||
|
190 | try-restart) | |
|
191 | log_daemon_msg "Restarting celery task worker server" "celeryd" | |
|
192 | set +e | |
|
193 | stop_worker --retry 30 | |
|
194 | RET="$?" | |
|
195 | set -e | |
|
196 | case $RET in | |
|
197 | 0) | |
|
198 | # old daemon stopped | |
|
199 | check_dev_null log_end_msg | |
|
200 | start_worker | |
|
201 | ;; | |
|
202 | 1) | |
|
203 | # daemon not running | |
|
204 | log_progress_msg "(not running)" | |
|
205 | log_end_msg 0 | |
|
206 | ;; | |
|
207 | *) | |
|
208 | # failed to stop | |
|
209 | log_progress_msg "(failed to stop)" | |
|
210 | log_end_msg 1 | |
|
211 | ;; | |
|
212 | esac | |
|
213 | ;; | |
|
214 | ||
|
215 | status) | |
|
216 | status_of_proc -p $CELERYD_PID_FILE $CELERYD celeryd && exit 0 || exit $? | |
|
217 | ;; | |
|
218 | ||
|
219 | *) | |
|
220 | log_action_msg "Usage: /etc/init.d/celeryd {start|stop|force-reload|restart|try-restart|status}" | |
|
221 | exit 1 | |
|
222 | esac | |
|
223 | ||
|
224 | exit 0 |
|
1 | NO CONTENT: file renamed from hg_app_daemon to init.d/hg_app_daemon |
|
1 | NO CONTENT: file renamed from hg_app_daemon2 to init.d/hg_app_daemon2 |
General Comments 0
You need to be logged in to leave comments.
Login now