Showing posts with label django. Show all posts
Showing posts with label django. Show all posts

Feb 14, 2012

Supervisord: Stop/Start gunicorn processes with XMLRPC and python

Supervisor: A Process Control System, as stated on supervisor's site. I used it to "supervise" gunicorn services which serves my Django sites.

I have a use case where I need to restart a gunicorn instance from Django itself. Supervisor supports XMLRPC, but instructions to use them weren't very well documented (no examples for lazy me). After some research (google + stackoverflow), I finally figured out how to do so.

As suggested from one of the stackoverflow post, supervisor is pure python implementation, so naturally it will use python libs to implement xmlrpc. That's exactly the codes we need to connect to supervisord's xmlrpc server.

from xmlrpclib import ServerProxy s = ServerProxy("http://localhost:10000") s.supervisor.stopProcess('process1') s.supervisor.startProcess('process1', False)

Sep 19, 2011

django-preferences #django Site Framework patch

django-preferences, an excellent preferences app for Django recently updated to support Django's Site Framework. If you're like me, not using South (lazyness, etc.), here's a quick script to create the new table.

This screwed up my site for about 5 minutes. Morale of the story, READ the CHANGELOG before upgrading. Git PULL is such a bad practice for production sites update =p

django-preferences changelog, 0.0.4 (2011-08-11) - 0.0.5 (2011-08-17)