Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multiple commands within Supervisor - Python/Linux

I'm using the amazing utility supervisord


I'm happily running a few apps editing the config file as follows:

[program: Django Dev Server]
command=python /path/to/project/manage.py runserver 127.0.0.1:8000

[program: MongoDB]
command=sudo /path/to/mongod

Now problem is that some apps need a few commands before they start up in order to prepare them for startup.

e.g. verifying conditions, cleaning folders, etc...


Any ideas?

like image 273
RadiantHex Avatar asked Dec 29 '10 19:12

RadiantHex


1 Answers

Instead of calling manage.py, write a script (call it, say, start_manage.py) which verifies conditions, cleans folders, etc, and then calls manage.py (using subprocess.Popen). Or, of course, start_manage could be a shell script if that fits your needs better.

Then change the config file to run

command=python start_manage.py
like image 128
unutbu Avatar answered Oct 26 '22 23:10

unutbu