From a78fdd5361f8e4e27eae893aedb21a0256c12a88 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Wed, 11 Feb 2009 11:42:29 -0800 Subject: Add Sinatra example --- examples/sinatra/README | 21 +++++++++++++++++++++ examples/sinatra/sinatra_example.rb | 7 +++++++ examples/sinatra/unicorn-sinatra-example | 13 +++++++++++++ 3 files changed, 41 insertions(+) create mode 100644 examples/sinatra/README create mode 100644 examples/sinatra/sinatra_example.rb create mode 100755 examples/sinatra/unicorn-sinatra-example (limited to 'examples') diff --git a/examples/sinatra/README b/examples/sinatra/README new file mode 100644 index 0000000..2928d16 --- /dev/null +++ b/examples/sinatra/README @@ -0,0 +1,21 @@ +This is an ultra simple Sinatra setup. + +sinatra_example.rb + + This is a generic Sinatra application, absolutely nothing needs to be + done to make this run with this application to run with Unicorn. + + +unicorn-sinatra-example + + this is the config file/application to execute with unicorn. You can + run it either standalone if "unicorn" is in your path, or by running: + + "unicorn unicorn-sinatra-example" + + +These examples do not load RubyGems. You'll have to set your RUBYLIB +environment variable appropriately for running these examples, for me +it's this: + +$HOME/gems/rack-0.9.1/lib:$HOME/gems/sinatra-0.9.0.2/lib:. diff --git a/examples/sinatra/sinatra_example.rb b/examples/sinatra/sinatra_example.rb new file mode 100644 index 0000000..70d05c2 --- /dev/null +++ b/examples/sinatra/sinatra_example.rb @@ -0,0 +1,7 @@ +#!/home/ew/bin/ruby +# this is a standalone Sinatra application, there is absolutely NOTHING +# special that has to be done in this file for running with Unicorn, +# instead take a look at the unicorn-sinatra-example script in this +# directory +require 'sinatra' +get('/') { "hello world\n" } diff --git a/examples/sinatra/unicorn-sinatra-example b/examples/sinatra/unicorn-sinatra-example new file mode 100755 index 0000000..3472d56 --- /dev/null +++ b/examples/sinatra/unicorn-sinatra-example @@ -0,0 +1,13 @@ +#!/home/ew/bin/ruby +# putting unicorn in the shebang won't work because unicorn itself is +# a ruby script, so the following is the next best thing: +exec('unicorn', $0) if $0 == __FILE__ + +# the below script is a standalone Sinatra application; absolutely +# nothing special needs to be done in this Sinatra app for running +# with Unicorn +require 'sinatra_example' + +# the following hash needs to be the last statement, as unicorn +# will eval this entire file +{ :app => Sinatra::Application } -- cgit v1.2.3-24-ge0c7