You are not logged in.
Glad I could help ![]()
There is one main django fcgi process and one spare fcgi process these are defined by the manage.py runfcgi command line options:
maxspare=NUMBER max number of spare processes or threads minspare=NUMBER min number of spare processes or threads maxchildren=NUMBER hard limit number of processes or threads
Changing these will give you more (or less) processes shown in ps
Regards,
Richard.
Offline
How would you write a custom restart script for both Nginx and Django in this instance? will the original startup lines e.g.
./sbin/nginx python2.5 manage.py runfcgi maxchildren=1 maxspare=1 method=prefork socket=/home/user/webapps/app/app.sock
in a cron job work?
Offline
./sbin/nginx && /usr/local/bin/python2.5 manage.py runfcgi maxchildren=1 maxspare=1 method=prefork socket=/home/user/webapps/app/app.sock
You should && them if nginx was restarted correctly then restart django.
Also please note I put the full path to python2.5 you should do the same for your manage.py as cron know nothing about the path it's executed in.
Offline
Thanks, that helps a lot! ![]()
Offline
Actually no it doesn't - the manage.py command doesn't check if the process is already running and starts another process each time ![]()
I need to be able to handle the following.
1) Both processes already running - don't do anything.
2) Nginx Running / Django Down - restart django.
3) Nginx Down / Django Running - restart nginx.
4) Both processes down - restart nginx then django.
My scripting skills are no that hot - anyone here able to help me - or at least point me in the right direction so that I don't get my wrists slapped by the WebFaction support team for using all their memory! ![]()
Thanks,
Richard.
Offline
I think you should look into using Supervisor: http://supervisord.org/
If you don't want to use that, then you can grep your process listing for whatever command and use the result as a condition, eg:
CMD="/usr/local/bin/python2.5 manage.py runfcgi maxchildren=1 maxspare=1 method=prefork socket=/home/user/webapps/app/app.sock" ps -u your_username -o command | grep -v grep | grep $CMD || $CMD
In other words:
1. Define the command that should be running
2. Get a list of your currently running commands
3. Look for the command
4. Run it if it's not there
Offline
Thanks! I'll check out Supervisor - It looks good, but I'll need to check it's effect on memory usage etc. I assume I can install it with the usual easy_install command e.g.
easy_install-2.5 -s $HOME/bin -d $HOME/lib/python2.5 supervisor
The other question of course being "How do I make sure that Supervisor is running (e.g. after a server reboot)?"
Also I've knocked up a bash script which I'm currently testing on my local server which uses pid files to start and stop nginx and django together. It also checks if they are already running before trying to start them.
Last edited by frozenskys (2009-09-03 09:49:05)
Offline
actually that's not needed just do
easy_install-2.5 supervisor
and our system will do the right thing.
As for the supervisor question that's a problem indeed. It's a recursive issue much like "who polices the police", in other words you need something to make sure that your something you have to make sure things are running is running
What I personally do is create cronjob to monitor supervisor, luckily for you we monitor that crond is always running ![]()
Offline
Indeed... "Who watches the watchmen?"
Thanks for all the help! ![]()
Offline
FYI I've been unable to make flup 1.0.3 work. It dies with
AttributeError: 'CGIRequest' object has no attribute '_timeout'
Solved by using flup 1.0.2
Offline
It seems like these instructions work if you are starting from scratch.
If one already has Django & an app up and running, can one switch over to nginx without reinstalling django, etc?
Thanks
Offline