Permalink
Browse files

fixed how to rackup so that it looked easy to use

  • Loading branch information...
1 parent d89946d commit 912adf548aac38492e5cd70570c688079a89de03 @ichiban committed Feb 12, 2012
Showing with 30 additions and 33 deletions.
  1. +16 −16 README.md
  2. +2 −2 example/async_sinatra/app.rb
  3. +3 −4 example/async_sinatra/config.ru
  4. +3 −3 example/sinatra/app.rb
  5. +3 −4 example/sinatra/config.ru
  6. +3 −4 example/upload/config.ru
View
@@ -29,33 +29,33 @@ Run Mongrel2.
Run a simple sinatra example,
cd sinatra
- export RACK_MONGREL2_SEND=tcp://127.0.0.1:9996
- export RACK_MONGREL2_RECV=tcp://127.0.0.1:9997
- export RACK_MONGREL2_UUID=9539ED88-1B33-4D19-A9F9-283E5BF11AC7
- rackup -s mongrel2
+ rackup -s Mongrel2 \
+ -O uuid=9539ED88-1B33-4D19-A9F9-283E5BF11AC7 \
+ -O send=tcp://127.0.0.1:9996 \
+ -O recv=tcp://127.0.0.1:9997
-run an async sinatra example or
+an async sinatra example or
cd async_sinatra
- export RACK_MONGREL2_SEND=tcp://127.0.0.1:9998
- export RACK_MONGREL2_RECV=tcp://127.0.0.1:9999
- export RACK_MONGREL2_UUID=AEE66029-E420-42E7-A7C8-6C37BBFC7B9F
- rackup -s mongrel2
+ rackup -s Mongrel2 \
+ -O uuid=AEE66029-E420-42E7-A7C8-6C37BBFC7B9F \
+ -O send=tcp://127.0.0.1:9998 \
+ -O recv=tcp://127.0.0.1:9999
-run an big-upload example
+a big-upload example.
cd upload
- export RACK_MONGREL2_CHROOT=..
- export RACK_MONGREL2_SEND=tcp://127.0.0.1:10000
- export RACK_MONGREL2_RECV=tcp://127.0.0.1:10001
- export RACK_MONGREL2_UUID=51226E47-AE49-4BC8-A9C6-BD7F6827E8A4
- rackup -s mongrel2
+ rackup -s Mongrel2 \
+ -O uuid=51226E47-AE49-4BC8-A9C6-BD7F6827E8A4 \
+ -O send=tcp://127.0.0.1:10000 \
+ -O recv=tcp://127.0.0.1:10001 \
+ -O chroot=..
## How to use in your projects
1. Get mongrel2 installed (http://mongrel2.org/wiki/quick_start.html)
1. Get your config for mongrel2 setup (see example directory)
-1. Add it to your Gemfile (gem 'em-rack-mongrel2', '~> 0.1.0')
+1. Add it to your Gemfile (gem 'em-rack-mongrel2')
1. You also need some sort of JSON parsing library installed, like Yajl or JSON (gem i yajl-ruby or gem i json). json-jruby will work too
1. Run Mongrel2
1. Run your rack application
@@ -5,8 +5,8 @@
class AsyncExample < Sinatra::Base
register Sinatra::Async
- aget '*' do
- EM.add_timer(5) do
+ aget '/' do
+ EM.add_timer(1) do
body request.env.to_json
end
end
@@ -1,8 +1,7 @@
-$: << File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'lib'))
-$:.unshift(File.expand_path('.')) # Ruby 1.9 doesn't have . in the load path...
+$LOAD_PATH.unshift File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'lib'))
+$LOAD_PATH.unshift File.expand_path('.') # Ruby 1.9 doesn't have . in the load path...
require 'rack/handler/mongrel2'
require 'app'
-Rack::Handler::Mongrel2.run AsyncExample, :uuid => 'sinatra', :block => true
-exit(0)
+run AsyncExample
View
@@ -1,7 +1,7 @@
require 'sinatra'
require 'yajl/json_gem'
-get '*' do
- sleep(5)
+get '/' do
+ sleep 1
request.env.to_json
-end
+end
@@ -1,8 +1,7 @@
-$: << File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'lib'))
-$:.unshift(File.expand_path('.')) # Ruby 1.9 doesn't have . in the load path...
+$LOAD_PATH.unshift File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'lib'))
+$LOAD_PATH.unshift File.expand_path('.') # Ruby 1.9 doesn't have . in the load path...
require 'rack/handler/mongrel2'
require 'app'
-Rack::Handler::Mongrel2.run Sinatra::Application, :uuid => 'sinatra', :block => true
-exit(0)
+run Sinatra::Application
View
@@ -1,8 +1,7 @@
-$: << File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'lib'))
-$:.unshift(File.expand_path('.')) # Ruby 1.9 doesn't have . in the load path...
+$LOAD_PATH.unshift File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'lib'))
+$LOAD_PATH.unshift File.expand_path('.') # Ruby 1.9 doesn't have . in the load path...
require 'rack/handler/mongrel2'
require 'app'
-Rack::Handler::Mongrel2.run Sinatra::Application, :uuid => 'sinatra', :block => true
-exit(0)
+run Sinatra::Application

0 comments on commit 912adf5

Please sign in to comment.