Skip to content

Host a pypipins instance using supervisor (Debian Wheezy)

Thomas G. edited this page Jun 2, 2015 · 2 revisions

This guide is for anyone looking for an easy way to host a pypipins instance on their own server. Although the install commands are specific to debian/ubuntu, most of the information here should be easy to transfer to other distributions as well.

First, let's install a few system dependencies.

apt-get install python-virtualenv redis-server

Create a non-root user to run the service - just in case:

useradd -m pypipins
passwd pypipins
su pypipins

Now, we're ready to install the package itself into a virtualenv (as user):

cd /home/pypipins
virtualenv env
source env/bin/activate
git clone https://github.com/badges/pypipins
cd pypipins
python setup.py develop

Note, that you will most likely also need the PRs #41 and #42 if they are not merged at this point.

To run the app, we can now type (as user pypipins)

/home/pypipins/env/bin/twistd -n web --class shields.shields.io

This is nice so far but what about autostart when the server is rebooted etc? There is a neat tool called supervisor which can do the job with just little configuration. Terminate your pypipins, back to the root account and:

apt-get install supervisor

Now edit /etc/supervisor/conf.d/pypipins.conf and put something in like this:

[program:pypipins]
directory=/home/pypipins
command=/home/pypipins/env/bin/twistd --nodaemon --logfile - web --class shields.shields.resource -p 8080
user=pypipins
autostart=true
autorestart=true
stderr_logfile=/home/pypipins/stderr.txt
stdout_logfile=/home/pypipins/stdout.txt

Finally issue the following commands to start your instance:

supervisorctl reread
supervisorctl update

By default supervisor is started after reboots and will automatically run your application.

Clone this wiki locally