Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'd like to use supervisord to run some commands for my Django project but I keep getting the following error:

supervisor.log:

2012-05-18 17:52:15,784 INFO spawnerr: can't find command 'source'

If I remove the "source" command, the log shows the same error: can't find command 'python'.

supervisord.conf excerpt:

[program:django]
directory=/home/mf/projects/djangopj/
command=beanstalkd -l 127.0.0.1 -p 11300
command=source /home/mf/virtualenvs/env/bin/activate
command=python manage.py command1
command=python manage.py command2
user=mf
autostart=true
autorestart=true

I tried removing the directory and adding the absolute path to the commands but I kept getting the same error.

I run supervisord with the following command:

supervisord -c supervisord.conf -l supervisor.log
share|improve this question
add comment

1 Answer

The source command is only available in bash, and the supervisor command is run by sh. I would recommend using a script to perform your commands:

/etc/supervisor/conf.d/my_app.conf

[program:my_app]
command = bash /path/to/app/init.sh
directory = /path/to/app/
user = ubuntu
autostart=true
autorestart=true

/path/to/app/init.sh

#!/bin/bash

beanstalkd -l 127.0.0.1 -p 11300
source /home/mf/virtualenvs/env/bin/activate    
python manage.py command1
python manage.py command2

The only problem is that supervisor will only have control of the script, not the command(s). If you have a situation where you want supervisor to manage and keep alive a specific process, I would recommend using exec in your bash init file, that way supervisor will have control of your process. E.g.

/path/to/app/init.sh

#!/bin/bash

exec beanstalkd -l 127.0.0.1 -p 11300

You may find this useful: http://sjsnyder.com/managing-virtualenv-apps-with-supervisor

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.