LEFT | RIGHT |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 | 2 |
3 import sys, os, pwd, subprocess | 3 import sys, os, pwd, subprocess |
4 | 4 |
5 app_dir = '/opt/discourse' | 5 app_dir = '/opt/discourse' |
6 airbrake_key = os.environ.get('AIRBRAKE_KEY', None) | 6 airbrake_key = os.environ.get('AIRBRAKE_KEY', None) |
7 | 7 |
8 # HOME environment variable isn't reliable when called via sudo | 8 # HOME environment variable isn't reliable when called via sudo |
9 home_dir = os.path.expanduser('~' + pwd.getpwuid(os.getuid()).pw_name) | 9 home_dir = os.path.expanduser('~' + pwd.getpwuid(os.getuid()).pw_name) |
10 | 10 |
(...skipping 22 matching lines...) Expand all Loading... |
33 callRailsCommand([os.path.join(app_dir, 'script', 'rails'), 'generate', 'airbr
ake', '--api-key', airbrake_key]) | 33 callRailsCommand([os.path.join(app_dir, 'script', 'rails'), 'generate', 'airbr
ake', '--api-key', airbrake_key]) |
34 | 34 |
35 with open(path, 'rb+') as handle: | 35 with open(path, 'rb+') as handle: |
36 # Prepend file with require 'airbrake', won't happen by default | 36 # Prepend file with require 'airbrake', won't happen by default |
37 data = handle.read() | 37 data = handle.read() |
38 handle.seek(0) | 38 handle.seek(0) |
39 print >>handle, "require 'airbrake'" | 39 print >>handle, "require 'airbrake'" |
40 handle.write(data) | 40 handle.write(data) |
41 | 41 |
42 def runInitCommands(): | 42 def runInitCommands(): |
43 service_path = '/etc/init.d/discourse-thin' | 43 service_path = '/etc/init.d/discourse' |
44 | 44 |
45 callRailsCommand(['bundle', 'install', '--deployment', '--without', 'test', '-
-without', 'development']) | 45 callRailsCommand(['bundle', 'install', '--deployment', '--without', 'test', '-
-without', 'development']) |
46 initAirBrake() | 46 initAirBrake() |
47 callRailsCommand(['bundle', 'exec', 'rake', 'assets:precompile']) | 47 callRailsCommand(['bundle', 'exec', 'rake', 'assets:precompile']) |
48 | 48 |
49 if os.path.exists(service_path): | 49 if os.path.exists(service_path): |
50 subprocess.check_call(['sudo', service_path, 'stop']) | 50 subprocess.check_call(['sudo', service_path, 'stop']) |
51 | 51 |
52 callRailsCommand(['bundle', 'exec', 'rake', 'db:migrate']) | 52 callRailsCommand(['bundle', 'exec', 'rake', 'db:migrate']) |
53 | 53 |
54 if os.path.exists(service_path): | 54 if os.path.exists(service_path): |
55 subprocess.check_call(['sudo', service_path, 'start']) | 55 subprocess.check_call(['sudo', service_path, 'start']) |
56 | 56 |
57 if __name__ == '__main__': | 57 if __name__ == '__main__': |
58 runInitCommands() | 58 runInitCommands() |
LEFT | RIGHT |