Camping apps as Services via Picnic

Camping is especially useful when you want to build small, simple HTTP network services. Ideally these should run as daemons, managed by Linux's init.d mechanism, with their configuration stored in the standard /etc directory. It would also be nice if you could easily distribute these applications as gems, so that end-users can install your service and have it up and running out of the box.

This is exactly what Picnic aims to do.

Picnic is a set of extensions for Camping that gives you:

  • A stadardized command-line interface for your app (i.e. a 'bin' script installed in /usr/bin)
  • A control script for starting and stopping your app as a service (also installed in /usr/bin)
  • Automatic, self-contained YAML-based configuration in /etc/<your app>
  • Robust postambles for running your app using webrick or mongrel

Additionally, Picnic allows you to easily add HTTP Basic and CAS authentication to your app's controllers.

A Picnic-enabled Camping app is also easy to package as a gem. Your end-user doesn't need to know anything about Camping, or about Ruby for that matter. All the user needs to do is install your gem, edit the /etc/<your app>/config.yml file, and start the service via <your app>-ctl start.

A step-by-step tutorial illustrating how Picnic is used is available at http://code.google.com/p/camping-picnic/wiki/PicnicTutorial. You can also have a look at the canonical camping Blog application, wrapped in Picnic, by downloading http://camping-picnic.googlecode.com/files/excample_picnic_app.tar.gz.

Here's a list of Camping applications that use Picnic. You might want to take a look at their source code for some ideas on what Picnic can do for you: