2
# ============================================
3
# celeryd - Starts the Celery worker daemon.
4
# ============================================
6
# :Usage: /etc/init.d/celeryd {start|stop|force-reload|restart|try-restart|status}
8
# :Configuration file: /etc/default/celeryd
10
# To configure celeryd you probably need to tell it where to chdir.
12
# EXAMPLE CONFIGURATION
13
# =====================
15
# this is an example configuration for a Python project:
17
# /etc/default/celeryd:
19
# # Where to chdir at start.
20
# CELERYD_CHDIR="/opt/Myproject/"
22
# # Extra arguments to celeryd
23
# CELERYD_OPTS="--time-limit=300"
25
# # Name of the celery config module.#
26
# CELERY_CONFIG_MODULE="celeryconfig"
28
# EXAMPLE DJANGO CONFIGURATION
29
# ============================
31
# # Where the Django project is.
32
# CELERYD_CHDIR="/opt/Project/"
34
# # Name of the projects settings module.
35
# export DJANGO_SETTINGS_MODULE="settings"
38
# CELERYD="/opt/Project/manage.py"
40
# # Extra arguments to manage.py
41
# CELERYD_OPTS="celeryd"
47
# Additional arguments to celeryd, see `celeryd --help` for a list.
50
# Path to chdir at start. Default is to stay in the current directory.
53
# Full path to the pidfile. Default is /var/run/celeryd.pid.
56
# Full path to the celeryd logfile. Default is /var/log/celeryd.log
59
# Log level to use for celeryd. Default is INFO.
62
# Path to the celeryd program. Default is `celeryd`.
63
# You can point this to an virtualenv, or even use manage.py for django.
66
# User to run celeryd as. Default is current user.
69
# Group to run celeryd as. Default is current user.
72
# Full path to the virtualenv environment to activate. Default is none.
76
# Required-Start: $network $local_fs $remote_fs
77
# Required-Stop: $network $local_fs $remote_fs
78
# Default-Start: 2 3 4 5
80
# Short-Description: celery task worker daemon
85
DEFAULT_CELERYD="/usr/bin/celeryd"
87
# /etc/init.d/ssh: start and stop the celery task worker daemon.
89
. /lib/lsb/init-functions
91
DEFAULT_FILE="<%= celeryd_default_file %>"
93
if test -f "$DEFAULT_FILE"; then
97
if [ "$NO_START" != "0" -a "$1" != "stop" ]; then
98
if [ "$VERBOSE" != "no" ]; then
99
log_warning_msg "Not starting celeryd - edit $DEFAULT_FILE and change NO_START to be 0."
105
CELERYD_LOG_FILE=${CELERYD_LOG_FILE:-${CELERYD_LOGFILE:-"/var/log/celeryd.log"}}
106
CELERYD_PID_FILE=${CELERYD_PID_FILE:-${CELERYD_PIDFILE:-"/var/run/celeryd.pid"}}
107
CELERYD_LOG_LEVEL=${CELERYD_LOG_LEVEL:-${CELERYD_LOGLEVEL:-"INFO"}}
109
CELERYD=${CELERYD:-$DEFAULT_CELERYD}
113
CELERYD_OPTS="$CELERYD_OPTS -f $CELERYD_LOG_FILE -l $CELERYD_LOG_LEVEL"
116
CELERYD_OPTS="$CELERYD_OPTS $2"
119
mkdir -p $(dirname "$CELERYD_PID_FILE")
120
mkdir -p $(dirname "$CELERYD_LOG_FILE")
122
# Extra start-stop-daemon options, like user/group.
123
if [ -n "$CELERYD_USER" ]; then
124
DAEMON_OPTS="$DAEMON_OPTS --chuid $CELERYD_USER"
125
chown "$CELERYD_USER" $(dirname "$CELERYD_LOG_FILE")
127
if [ -n "$CELERYD_GROUP" ]; then
128
DAEMON_OPTS="$DAEMON_OPTS --group $CELERYD_GROUP"
131
if [ -n "$CELERYD_CHDIR" ]; then
132
DAEMON_OPTS="$DAEMON_OPTS --chdir $CELERYD_CHDIR"
136
# Are we running from init?
138
([ "$previous" ] && [ "$runlevel" ]) || [ "$runlevel" = S ]
143
if [ ! -c /dev/null ]; then
144
if [ "$1" = log_end_msg ]; then
145
log_end_msg 1 || true
147
if ! run_by_init; then
148
log_action_msg "/dev/null is not a character device!"
155
export PATH="${PATH:+$PATH:}/usr/sbin:/sbin"
159
cmd="start-stop-daemon --stop \
162
--pidfile $CELERYD_PID_FILE"
171
cmd="start-stop-daemon --start $DAEMON_OPTS \
177
--pidfile $CELERYD_PID_FILE
178
--exec $CELERYD -- $CELERYD_OPTS"
179
if [ -n "$VIRTUALENV" ]; then
180
source $VIRTUALENV/bin/activate
194
log_daemon_msg "Starting celery task worker server" "celeryd"
198
log_daemon_msg "Stopping celery task worker server" "celeryd"
203
echo "Use start+stop"
207
log_daemon_msg "Restarting celery task worker server" "celeryd"
208
stop_worker --oknodo --retry 30
209
check_dev_null log_end_msg
214
log_daemon_msg "Restarting celery task worker server" "celeryd"
216
stop_worker --retry 30
222
check_dev_null log_end_msg
227
log_progress_msg "(not running)"
232
log_progress_msg "(failed to stop)"
239
status_of_proc -p $CELERYD_PID_FILE $CELERYD celeryd && exit 0 || exit $?
243
log_action_msg "Usage: /etc/init.d/celeryd {start|stop|force-reload|restart|try-restart|status}"