Skip to content

Commit

Permalink
* lib/camping/fastcgi.rb: first stab at a FastCGI version of TheCamp…
Browse files Browse the repository at this point in the history
…ingServer.
  • Loading branch information
_why committed Jul 6, 2006
1 parent e16c430 commit b125431
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions lib/camping/fastcgi.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
# So where do you use the Camping::FastCGI class? Use it in your application's
# postamble and then you can point your web server directly at your application.
# See Camping::FastCGI docs for more.
require 'camping'
require 'fcgi'

module Camping
Expand Down Expand Up @@ -89,6 +90,29 @@ def self.start(app)
cf.start
end

# Serve an entire directory of Camping apps. (See
# http://code.whytheluckystiff.net/camping/wiki/TheCampingServer.)
#
# Use this method inside your FastCGI dispatcher:
#
# #!/usr/local/bin/ruby
# require 'rubygems'
# require 'camping/fastcgi'
# Camping::Models::Base.establish_connection :adapter => 'sqlite3', :database => "/path/to/db"
# Camping::FastCGI.serve("/home/why/cvs/camping/examples")
#
def self.serve(path, index=nil)
require 'camping/reloader'
fast = Camping::FastCGI.new
fast.mount("/", index) if index
apps = Dir[File.join(path, '*.rb')].map do |script|
app = Camping::Reloader.new(script)
fast.mount("/#{app.mount}", app)
app
end
fast.start
end

private

def match(path, mount)
Expand Down

0 comments on commit b125431

Please sign in to comment.