26 Aug 2008 nbm   » (Journeyer)

Updating the TechGeneral deployment environment

Over the past few days, I've been putting the final touches on TechGeneral before letting anyone know about it.  The process from development to deployment has been surprisingly simple.

TechGeneral runs gibe, the web log server application I wrote for my personal web log.  Gibe is written in Python, using the TurboGears 1 mega-framework.

When deploying Python applications, using virtualenv (or something equivalent) is the best way to go.  Each virtual Python environment contains the particular versions of libraries necessary to run the applications that run in that environment.  TurboGears 1 is getting a bit old (although that's entirely relative), and needs some older versions of libraries.  No problem accomodating that with virtualenv.

Gibe itself, its plugins, and themes written for it (which are just plugins) are all Python packages, and are most easily installed using easy_install within the virtual Python environment.

This was my first real-life use of mod_wsgi, which manages a WSGI application's lifecycle.  I created a simple .wsgi file using the TurboGears example, and set up a line or two in my Apache config, and I had a fully managed Python process running as a specified user and using the virtual Python environment I'd set up.

At this point, moving from development to deployment was just a matter of creating Python packages, uploading them, installing them with easy_install, and using the Unix command "touch" on the .wsgi file to tell mod_wsgi to redeploy the application.

If a mistake happens, I just remove the new version of the offending package and touch the .wsgi file.

I created a simple development-side alias to create a new Python source distribution of the current Gibe plugin (or Gibe itself), and upload it to my server:

alias tgu="python setup.py sdist && \
scp `ls -trc1 dist/* | tail -1` \

On the server side, I have a simple function (paths removed for simplicity):

tginstall() { easy_install "$@" && \
touch mod_wsgi/techgeneral.wsgi ; }

(I supposed if I got really bored, I could create one command on the development machine to push it up, install it, and reload the server.)

Syndicated 2008-08-20 12:28:43 (Updated 2008-08-20 20:52:18) from Neil Blakey-Milner

Latest blog entries     Older blog entries

New Advogato Features

New HTML Parser: The long-awaited libxml2 based HTML parser code is live. It needs further work but already handles most markup better than the original parser.

Keep up with the latest Advogato features by reading the Advogato status blog.

If you're a C programmer with some spare time, take a look at the mod_virgule project page and help us with one of the tasks on the ToDo list!