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

Unified Diff: modules/discourse/files/init-discourse

Issue 9422170: Run Discourse via Thin rather than FGCI (Closed)
Patch Set: Created Feb. 27, 2013, 1:34 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/init-discourse
===================================================================
--- a/modules/discourse/files/init-discourse
+++ b/modules/discourse/files/init-discourse
@@ -9,25 +9,16 @@ airbrake_key = os.environ.get('AIRBRAKE_
# HOME environment variable isn't reliable when called via sudo
home_dir = os.path.expanduser('~' + pwd.getpwuid(os.getuid()).pw_name)
env = dict(os.environ)
env['GEM_HOME'] = os.path.join(home_dir, '.gems')
env['RAILS_ENV'] = 'production'
def preprocessFiles():
- gemfile_path = os.path.join(app_dir, 'Gemfile')
- handle = open(gemfile_path, 'rb')
- if "gem 'fcgi'" not in map(str.strip, handle.readlines()):
- handle.close()
- handle = open(gemfile_path, 'ab')
- print >>handle, "gem 'fcgi'"
- print >>sys.stderr, 'Added fcgi gem to Gemfile'
- handle.close()
-
secret_path = os.path.join(app_dir, 'config', 'initializers', 'secret_token.rb')
handle = open(secret_path, 'rb')
if handle.read().find('SET_SECRET_HERE') >= 0:
if secret != None:
handle.close()
handle = open(secret_path, 'wb')
print >>handle, 'Discourse::Application.config.secret_token = "%s"' % secret
print >>sys.stderr, 'Defined our secret in config/initializers/secret_token.rb'
@@ -51,25 +42,25 @@ def initAirBrake():
if data.find(airbrake_key) >= 0:
return
else:
os.remove(path)
callRailsCommand([os.path.join(app_dir, 'script', 'rails'), 'generate', 'airbrake', '--api-key', airbrake_key])
def runInitCommands():
rake_path = os.path.join(env['GEM_HOME'], 'bin', 'rake')
- spawn_path = '/etc/init.d/spawn-fcgi'
+ service_path = '/etc/init.d/discourse-thin'
callRailsCommand(['bundle', 'install'])
initAirBrake()
callRailsCommand([rake_path, 'assets:precompile'])
- if os.path.exists(spawn_path):
- subprocess.call(['sudo', spawn_path, 'stop'])
+ if os.path.exists(service_path):
+ subprocess.call(['sudo', service_path, 'stop'])
callRailsCommand([rake_path, 'db:migrate'])
- if os.path.exists(spawn_path):
- subprocess.call(['sudo', spawn_path, 'start'])
+ if os.path.exists(service_path):
+ subprocess.call(['sudo', service_path, 'start'])
if __name__ == '__main__':
preprocessFiles()
runInitCommands()

Powered by Google App Engine
This is Rietveld