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