ask/celery — Issue #588: celery 2.4.6 - one out of three celeryd instances fails to start (FreeBSD 9)
Author: toudi
Created: 2012-01-12 22:29:05+00:00
State: open

hello.

i'm having very strange issues with the init.d script on freebsd.

first of all, let me clarify that i am trying to use multiple celery instances on the same machine as i have multiple projects using celery. I downloaded celeryd init script and put it in /usr/local/etc/rc.d directory. i created the settings in /etc/default/celeryd using those provided here http://docs.celeryproject.org/en/latest/cookbook/daemonizing.html#example-django-configuration-using-virtualenv . I have also created files for projects in /etc/default/. Here's a diff of such definition against default one:

```diff
$ cd /etc/default
$ diff project celeryd
2c2
< CELERYD_NODES="project-w1"
---
> CELERYD_NODES="w1"
7c7
< CELERYD_CHDIR="/usr/local/www/project/htdocs"
---
> CELERYD_CHDIR="/usr/local/www/another-project/htdocs"
```

And the diff of init.d file:

```diff
$ cd /usr/local/etc/rc.d
$ diff celeryd celeryd-project
31c31
< CELERY_DEFAULTS=${CELERY_DEFAULTS:-"/etc/default/celeryd"}
---
> #CELERY_DEFAULTS=${CELERY_DEFAULTS:-"/etc/default/celeryd"}
33,35c33,35
< test -f "$CELERY_DEFAULTS" && . "$CELERY_DEFAULTS"
< if [ -f "/etc/default/celeryd" ]; then
< . /etc/default/celeryd
---
> #test -f "$CELERY_DEFAULTS" && . "$CELERY_DEFAULTS"
> if [ -f "/etc/default/project" ]; then
> . /etc/default/project
```

Now here's the interesing / strange part. I can execute the first daemon of celery without any problems:

```bash

$ sudo service celeryd start
celeryd-multi v2.4.6
> Starting nodes...
> w1.api4: OK
$ ps ax | grep celery
82547 ?? SJ 0:00.63 /usr/local/www/virtualenv/django/bin/python /usr/local/www/project/htdocs/manage.py celeryd --time-limit=1800 --concurrency=2 -n w1.api4 --loglevel=INFO --logfile=/var/log/celery/w1.log --pidfile=/var
```

when i try to execute another celeryd instance, it fails silently:

```bash
$ sudo service celeryd-another-project start
celeryd-multi v2.4.6
> Starting nodes...
> another-project-w1.api4: OK
$ ps ax | grep celery
$
```

Now here's what's really strange: I added the --verbose argument to CELERYD_OPTS, like so:

```bash
# Extra arguments to celeryd
CELERYD_OPTS="--time-limit=1800 --concurrency=2 --verbose"
```

Now when i execute the second project celery init script i can see the command:

```
$ sudo service celeryd-another-project start
celeryd-multi v2.4.6
> Starting nodes...
> another-project-w1.api4: /usr/local/www/virtualenv/django/bin/python /usr/local/www/another-project/htdocs/manage.py celeryd_detach --time-limit=1800 --concurrency=2 --gid=celery -n project-w1.api4 --logfile=/var/log/celery/project-w1.log --loglevel=INFO --uid=celery --pidfile=/var/run/celery/project-w1.pid --workdir=/usr/local/www/another-project/htdocs
OK
```

When i copy and paste this command into the shell, celeryd executes without any problem and i can see it in the process list.
Another symptom i noticed was - when i executed the script with the service command, celeryd initiated, but failed to recognized any tasks. When i used copy/paste method described above - everything went just fine.

Am i missing something?

best regards,
toudi.