Blog Archive for November 24, 2010

Running supervisorctl as non-root

November 24, 2010

By default, supervisorctl communicates with supervisord using a unix socket. This socket is only accessible to root. If you want to be able to run supervisorctl as a normal user, and thus allow the starting and stopping of individual services as that normal user, you need to change this to …

Starting Supervisord at boot

November 24, 2010

Here's an init.d script for starting supervisord at boot:

# Supervisord auto-start
#
# description: Auto-starts supervisord
# processname: supervisord
# pidfile: /var/run/supervisord.pid

SUPERVISORD=/usr/bin/supervisord
SUPERVISORCTL=/usr/bin/supervisorctl

case $1 in
start)
        echo -n "Starting supervisord: "
        $SUPERVISORD
        echo
        ;;
stop)
        echo -n "Stopping supervisord: "
        $SUPERVISORCTL shutdown
        echo
        ;;
restart)
        echo -n …

Supervisord Gunicorn

November 24, 2010

Now that we know the basics of supervisord (http://drumcoder.co.uk/blog/2010/nov/24/supervisord-basics/), we can put it to work starting gunicorn.

Here's the basic configuration you'll need for a gunicorn server:

[program:bbr]
command=gunicorn_django -b localhost:8003 -p /tmp/gunicorn-bbr-pid settingsstaging.py
directory=/home/user/web/bbr
environment=PYTHONPATH=/home/user/web/bbr
user=www-data
autostart= …

Supervisord Basics

November 24, 2010

supervisord is a system for starting and stopping processes on Unix boxes.

Installing

To install on Debian (assuming python setuptools are installed):

# easy_install supervisor

Once it has installed, run echo_supervisord_conf at a command prompt to get an example config file. You can then redirect this to /etc/supervisord.conf to get …

Hudson Calling Selenium Tests

November 24, 2010

I wanted to have Hudson pick a Django project from Mercurial, spin it up using Gunicorn, and then run some selenium tests against it. This is on a Debian server, the same server as the Mercurial repository is located on.

I already had my code coming out of Mercurial to …

Dynamic Paths in Django

November 24, 2010

Here's how to avoid storing hard coded path names in Django.

manage.py

In manage.py, change the top of the file to setup sys.path like this:

import os,sys
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
PROJECT_DIR = os.path …