Created
May 1, 2010 17:10
Revisions
-
techarch revised this gist
May 1, 2010 . 2 changed files with 5 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,5 @@ Options +FollowSymLinks +ExecCGI RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ /dispatch.fcgi/$1 [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},QSA,L] ErrorDocument 500 "Application error: Ruby Camping application failed to start properly This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -35,6 +35,10 @@ class OneAndOneCGIAdapter def call(env) env['SCRIPT_NAME'] = '/' # Assuming your .htaccess has: # RewriteRule ^(.*)$ /dispatch.fcgi/$1 [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},QSA,L] env['HTTP_AUTHORIZATION'] = env['REDIRECT_REDIRECT_HTTP_AUTHORIZATION'] || '' begin @app.call(env) rescue Exception => ex -
techarch revised this gist
May 1, 2010 . 1 changed file with 4 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -38,8 +38,10 @@ class OneAndOneCGIAdapter begin @app.call(env) rescue Exception => ex msg = "<h1>Error: #{$!}</h1>" msg << "<p>#{Time.now}</p>" msg << '<ol>' ex.backtrace.each { | t | msg << "<li>#{t}</li><br/>" } msg << '</ol>' logger = Logger.new(LOGPATH) -
techarch revised this gist
May 1, 2010 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -8,7 +8,7 @@ require 'camping' require 'your_camping_app.rb' LOGPATH = File.dirname(__FILE__) + '/your_camping_app.log' logger = Logger.new(LOGPATH) -
techarch revised this gist
May 1, 2010 . 1 changed file with 6 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -8,7 +8,9 @@ require 'camping' require 'your_camping_app.rb' LOGPATH = File.dirname(__FILE__) + '/portal.log' logger = Logger.new(LOGPATH) module Rack class Request @@ -26,8 +28,8 @@ module Rack end class OneAndOneCGIAdapter def initialize(app) @app = app end def call(env) @@ -40,6 +42,7 @@ class OneAndOneCGIAdapter ex.backtrace.each { | t | msg << '<li>' + t + '</li><br/>' } msg << '</ol>' logger = Logger.new(LOGPATH) logger.error msg [200,{"Content-Type" => "text/html"},msg] -
techarch created this gist
May 1, 2010 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,5 @@ Options +FollowSymLinks +ExecCGI RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ /dispatch.cgi/$1 [QSA,L] ErrorDocument 500 "Application error: Ruby Camping application failed to start properly This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,53 @@ #!/usr/bin/ruby Dir.chdir '/path/to/your/camping/app' require 'rubygems' require 'rack' require 'camping' require 'your_camping_app.rb' logger = Logger.new(File.dirname(__FILE__) + '/your_camping_app.log') module Rack class Request alias :original_rack_POST :POST def POST begin original_rack_POST rescue Errno::ESPIPE @env["rack.request.form_hash"] end end end end class OneAndOneCGIAdapter def initialize(app) @app = app end def call(env) env['SCRIPT_NAME'] = '/' begin @app.call(env) rescue Exception => ex msg = '<h1>Error: ' + $! +'</h1><br/><ol>' ex.backtrace.each { | t | msg << '<li>' + t + '</li><br/>' } msg << '</ol>' logger.error msg [200,{"Content-Type" => "text/html"},msg] end end end adapter = OneAndOneCGIAdapter.new(YourCampingApp) logger.info "start request for #{ENV['SCRIPT_URI']}" Rack::Handler::CGI.run adapter , :Port => 80