|
|
Picnic makes it easy(ier) to distribute and run Camping-based applications as well-behaved stand-alone Linux servers (works on Windows too!).
The idea is that one ought to be able to install a Camping app as a gem, and run it as a Linux service (almost) right out of the box. To this end, Picnic provides a supporting framework that includes the following:
- YAML configuration: When your application is first launched, it automatically creates a default configuration in /etc/<your app>. As a Camping developer you can easily access the contents of this configuration from anywhere in your app (for example: Conf[:some_setting]).
- Robust postambles: The end-user selects the web server they want to use (webrick or mongrel) by editing your app's YAML configuration file. The built-in postambles take care of all the various idiosyncrasies of running your app as a webrick or mongrel daemon.
- Command-line frontend: Your app gets a simple front-end 'bin' script, installable into your /usr/bin. The script takes standard command-line options like the location of the conf file, program verbosity, etc.
- Service control frontend: Similar to the command-line frontend, your app gets a 'bin-ctl' script usable in init.d for stopping/starting your app as a standard Linux service.
- Authentication: Easily add authentication into your application. Currently Basic HTTP and CAS authentication methods are implemented.
Installation
Picnic is available as a RubyGem. To install it you will need:
- Ruby 1.8.4 or later
- RubyGems
- It is assumed that you're familliar with Camping, since this is the framework Picnic is designed to support. Note that you do not have to install Camping separately, since Picnic includes Camping 1.5.180.
- It is also recommended that you grab the newgem RubyGem generator utility. This is useful for packaging your Camping app as a RubyGem and is referred to in the PicnicTutorial.
To install Picnic:
gem install picnic
You may need to run this as root:
sudo gem install picnic
That's it. You can now use Picnic in your code:
require 'rubygems' require 'picnic'
Usage
For detailed, step-by-step instructions for building a Picnic-based application see the PicnicTutorial.
If you prefer to jump right in, have a look at the sample picnic application and also at Howlr, Taskr, and RubyCAS-Server for examples of Picnic-enabled apps.
