Question

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?

Was it helpful?

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.

OTHER TIPS

I'm not an upstart expert - but I think the problem is that you're trying to sudo those commands. If upstart is using the stock "sudo", you're trying to run shell functions as commands - which you can't do.

Try dropping the sudo part of this to see if it works.

pre-start script
    export WORKON_HOME=~/.envs
    source /usr/local/bin/virtualenvwrapper.sh
    workon env1
end script
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top