May 3, 2012

It has been a while since I've updated this site (including any new blog posts!) so I thought I would redesign the entire thing using Node.js. You are looking at the result.

It is a very simple app which can parse the static posts from the original Octopress site. It uses Express for the routing and Stylus for the styling and most of it is written in Coffeescript.

It integrates with github to pull all the activity for a specified user and displays it in the activity list in the footer and with mailgun to send emails when interesting things happen. In the future, I would like to add twitter integration as well.

September 22, 2011

I have been looking for a simple blogging engine to host my new Codefall blog for the last couple of months. Most of the contenders required me to install application servers (e.g. PHP, Java, etc) and an SQL server on my little Linode. That didn't seem like a great use of resources.

So I wrote my own... It was very simple - it consisted of text files with a header describing the post's title and date and the post content was markdown. That worked but I really didn't want to maintain it nor did I want to add more functionality since I am spending all my waking hours working on my startup.

Then I found Octopress. It did what my simple blogging engine did but it did it well. Lots of functionality and options and a nice default theme.

And I didn't need to run any servers on my little Linode since Octopress generates a static site! I just installed the Octopress framework on my laptop, generated the blog and deployed to my Linode using rsync. Awesome, right?

I'm running Mac OS X 10.7.1 (which is a steaming pile but that's another story) - here is what I did to get Octopress up and running:

brew install ruby     # requires 1.9.2 but OS X only has 1.8.7
gem install bundler   # the "bundle" command deals with ruby dependencies

git clone git:// octopress

cd octopress
bundle install  # install octopress dependencies
rake install    # install the default theme

vi Rakefile     # change the first 2 options - ssh_user & document_root
vi _config.yml  # change the top few options as necessary

rake generate   # create the site
rake deploy     # deploy the site

This requires your OS X box to have some applications already installed (e.g. brew, git, gcc, etc).

On the server, I just added another nginx server configuration like the following example and I was finished.

server {
listen   80; ## listen for ipv4
listen   [::]:80 default ipv6only=on; ## listen for ipv6

access_log  /var/log/nginx/example.access.log;

location / {
    root   /path/to/deployed/files;

The posts are added under "source/_posts" with the format described here. The useful "rake preview" command allowed me to test my changes locally at http://localhost:4000.

Exactly the solution I was looking for.

September 10, 2011

To configure a Tornado server to run behind an nginx proxy is relatively easy. The following steps were using to configure a Ubuntu 10.10 server:

  • Start the Tornado server on some non-standard port - e.g. 8888
  • Tell nginx to proxy requests to your Tornado server on port 8888
  • Optionally you can have nginx handle all the static content (e.g. images, css, etc.) to reduce the load on the Tornado server

Configuring the Tornado server to run on a port is as simple as modifying the parameter passed to the listen function of the application object.

application = tornado.web.Application(routes, **settings)

And then configure nginx to pass requests to your Tornado server. The following configuration snippet is meant to be included from the default Ubuntu 10.10 nginx server configuration. It includes the optional third step which tries to serve a static page from the filesystem before passing the request off the the upstream tornado server.

upstream example_servers {

server {
  listen 80;
  access_log /var/log/nginx/example.access.log;

  location / {
    root /opt/example/static;
    try_files $uri @example;

  location @example {
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_pass       http://example_servers;

This snippet assumes the name of your site is "example" and it is located in /opt. To use it replace the "example" string with the actual name of your project.

September 9, 2011

Combining python environments defined inside a virtualenv and a daemon process watched by supervisord posed a bit of a problem since environments defined by virtualenv need to be activated before they can be used using the "/bin/activate" shell script.

The best solution I found was inspired by this post resulted in this small shell script:


if [ -z $VIRTUAL_ENV ]; then
  echo "usage: $0 </path/to/virtualenv> <cmd>"
  exit 1

. $VIRTUAL_ENV/bin/activate
shift 1
exec "$@"

Make the script executable and add the following section to your supervisord configuration and your script will be running in your specified virtualenv and monitored by supervisord.

command = /path/to/ /path/to/virtualenv python /path/to/