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

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

Issue 4924880143253504: Issue 2471 - Update our Discourse instance (Closed)
Patch Set: Check out correct revision Created May 12, 2015, 10:15 a.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
@@ -1,54 +1,30 @@
#!/usr/bin/env python
import sys, os, pwd, subprocess
app_dir = '/opt/discourse'
-airbrake_key = os.environ.get('AIRBRAKE_KEY', None)
# 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['RAILS_ENV'] = 'production'
# See http://meta.discourse.org/t/tuning-ruby-and-rails-for-discourse/4126
env['RUBY_GC_MALLOC_LIMIT'] = '90000000'
def callRailsCommand(command):
subprocess.check_call(command, env=env, cwd=app_dir)
-def initAirBrake():
- if airbrake_key == None:
- return
-
- path = os.path.join(app_dir, 'config', 'initializers', 'airbrake.rb')
- if os.path.exists(path):
- with open(path, 'rb') as handle:
- data = handle.read()
-
- 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])
-
- with open(path, 'rb+') as handle:
- # Prepend file with require 'airbrake', won't happen by default
- data = handle.read()
- handle.seek(0)
- print >>handle, "require 'airbrake'"
- handle.write(data)
-
def runInitCommands():
service_path = '/etc/init.d/discourse'
callRailsCommand(['bundle', 'install', '--deployment', '--without', 'test', '--without', 'development'])
- initAirBrake()
callRailsCommand(['bundle', 'exec', 'rake', 'db:migrate'])
callRailsCommand(['bundle', 'exec', 'rake', 'assets:precompile'])
if os.path.exists(service_path):
subprocess.check_call(['sudo', service_path, 'stop'])
if os.path.exists(service_path):
subprocess.check_call(['sudo', service_path, 'start'])

Powered by Google App Engine
This is Rietveld