Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #9 from myfreeweb/master

Actual Rack usage
  • Loading branch information...
commit 166c2f4ea1f5197a93f81ae5558ab60618a61556 2 parents 4bee859 + 82b82a7
@charliesome authored
Showing with 17 additions and 11 deletions.
  1. +15 −10 bin/racer
  2. +2 −1  racer.gemspec
View
25 bin/racer
@@ -1,6 +1,7 @@
#!/usr/bin/env ruby
require "optparse"
require "racer"
+require "rack"
options = { address: "0.0.0.0", port: 3000, rackup: "#{Dir.pwd}/config.ru" }
@@ -14,20 +15,24 @@ OptionParser.new do |opts|
opts.on "-p PORT", "--port PORT", "Port to listen on" do |p|
options[:port] = p.to_i
end
+
+ opts.on "-e ENVIRONMENT", "--env ENVIRONMENT", "Rack environment" do |e|
+ options[:env] = e
+ end
opts.on "--rackup FILE", "Use specified file as rackup file" do |ru|
options[:rackup] = ru
end
end.parse!
-Object.send :define_method, :run do |app|
- puts "Racer #{Racer::VERSION}"
- puts "Listening on #{options[:address]}:#{options[:port]}"
- begin
- Racer.run options[:address], options[:port], app
- ensure
- puts "Served #{Racer::Stats.total_requests} requests."
- end
-end
+ENV["RACK_ENV"] = options[:env] || ENV["RACK_ENV"] || "development"
+
+app, rack_options = Rack::Builder.parse_file options[:rackup]
-load options[:rackup]
+puts "Racer #{Racer::VERSION}"
+puts "Listening on #{options[:address]}:#{options[:port]}"
+begin
+ Racer.run options[:address], options[:port], app
+ensure
+ puts "Served #{Racer::Stats.total_requests} requests."
+end
View
3  racer.gemspec
@@ -24,4 +24,5 @@ Gem::Specification.new do |s|
s.executables = ["racer"]
s.required_ruby_version = ">= 1.9.2"
-end
+ s.add_dependency "rack", ["~> 1.2"]
+end
Please sign in to comment.
Something went wrong with that request. Please try again.