Search code examples
pythondjangoubuntuvirtualenvupstart

Upstart problem with virtualenv - Python/Ubuntu


I'm using upstart in order to start this script:

pre-start script
    sudo export WORKON_HOME=~/.envs
    sudo source /usr/local/bin/virtualenvwrapper.sh
    sudo workon env1
end script

start on runlevel [2345]
stop on runlevel [!2345]

exec python /home/radiant/www/staging/django_project/manage.py celerycam > /home/radiant/www/staging/logs/celerycam.log

respawn

respawn limit 10 90

Without the pre-start script it works, with the script block I get this:

start: Job failed to start


My fix:

Instead of sourcing using the Virtual Environment's python interpreter works fine :)

should have thought about this before!


Any ideas what this could be?


Solution

  • It could be what ~ resolves to when running under Upstart. Try specifying an absolute path for WORKON_HOME and check that the user the job runs as has permissions to all relevant directories and files.