Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: modules/discourse/files/discourse.fcgi

Issue 9377123: Set up proper FastCGI environment for Discourse and use nginx (Closed)
Patch Set: Converted init_discourse script to Python Created Feb. 18, 2013, 2:03 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: modules/discourse/files/discourse.fcgi
===================================================================
new file mode 100644
--- /dev/null
+++ b/modules/discourse/files/discourse.fcgi
@@ -0,0 +1,25 @@
+#!/usr/bin/ruby
+
+Dir.chdir(File.dirname(__FILE__))
+ENV['RAILS_ENV'] ||= 'production'
+ENV['GEM_HOME'] = File.expand_path('~discourse/.gems')
+ENV['GEM_PATH'] = File.expand_path('~discourse/.gems') + ':/var/lib/gems/1.9.1'
Felix Dahlke 2013/02/21 15:56:02 How about ENV['GEM_HOME'] + ':/var/lib/gems/1.9.1'
Wladimir Palant 2013/02/22 13:52:54 Done that and also got rid of the hardcoded user n
Felix Dahlke 2013/02/22 13:56:01 That should do: gem env gemdir
Wladimir Palant 2013/02/22 13:59:34 And now from inside Ruby please, without starting
Wladimir Palant 2013/02/27 17:03:02 Now that we are no longer using FCGI this should b
+
+require 'fcgi'
+require_relative 'config/environment'
+
+class Rack::PathInfoRewriter
+ def initialize(app)
+ @app = app
+ end
+
+ def call(env)
+ env.delete('SCRIPT_NAME')
+ parts = env['REQUEST_URI'].split('?')
+ env['PATH_INFO'] = parts[0]
+ env['QUERY_STRING'] = parts[1].to_s
+ @app.call(env)
+ end
+end
+
+Rack::Handler::FastCGI.run Rack::PathInfoRewriter.new(Discourse::Application)

Powered by Google App Engine
This is Rietveld