1

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?

Community
  • 1
  • 1
RadiantHex
  • 24,907
  • 47
  • 148
  • 244

2 Answers2

2

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
1

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.

Vinay Sajip
  • 95,872
  • 14
  • 179
  • 191