Question

I don't have a manage.py and use different settings for DJANGO_SETTINGS_MODULE and django-admin.py to switch between development and production environments. This is suggested both by Django docs and pydanny in "2 Scoops of Django".

My project resides in /home/dotcloud/current/bipolar. My settings are in /home/dotcloud/current/bipolar/bipolar/settings/dotcloud.py, following Django 1.5 directory structure. DJANGO_SETTINGS_MODuLE is set in dotcloud.yml to be bipolar.settings.dotcloud.

I'm having trouble getting things to run Dotcloud. When I just follow the example tutorial, I already have to add a export PYTHONPATH=/home/dotcloud/current/(hellodjango|bipolar):$PYTHONPATH to the postinstall script.

Things get really hairy when using the supervisor to launch celery. I'm trying to run the command django-admin.py celery worker. But no matter how I try to get my PYTHONPATH set to /home/dotcloud/current/bipolar, it's not picked up. I've tried both

command = "PYTHONPATH=/home/dotcloud/current/bipolar:$PYTHONPATH django-admin.py celery worker --loglevel=INFO -E"

and

environment=PYTHONPATH="/home/dotcloud/current/bipolar"

in the supervisord.conf to no avail. I've tried moving things to a shell script, setting the path before running it... That works for postinstall, after all! And it does work when running it on the shell, but it doesn't work when the machine is deployed.

So any help is suggested!

edit: I have since tried multiple things. I've re-added a manage.py that both sets the correct sys.path and DJANGO_SETTINGS_MODULE, to no avail. Finally, I've added a python-worker service which has achieved nothing apart from failing twice as much (supervisord.conf gets read on both services, huh?).

Was it helpful?

Solution 2

Turns out the docs are wrong. One can't set directory = $HOME/current/ in supervisord.conf. Replace it with /home/dotcloud/current/ and you're good to go.

I still couldn't get django-admin.py to work; I'm assuming it gets called with a Python binary outside of the virtualenv. I find manage.py a bit hacky; is there a better way?

My working supervisord.conf:

[program:celery_beat]
directory = /home/dotcloud/current/bipolar/
stderr_logfile = /var/log/supervisor/%(program_name)s_error.log
stdout_logfile = /var/log/supervisor/%(program_name)s.log
command = /home/dotcloud/env/bin/python manage.py celery beat --loglevel=INFO

[program:celery_worker]
directory = /home/dotcloud/current/bipolar/
stderr_logfile = /var/log/supervisor/%(program_name)s_error.log
stdout_logfile = /var/log/supervisor/%(program_name)s.log
command = /home/dotcloud/env/bin/python manage.py celery worker -E --loglevel=INFO

OTHER TIPS

I know this may not work but have you tried:

command = "cd /home/dotcloud/current/bipolar && django-admin.py celery worker --loglevel=INFO -E"
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top