| OLD | NEW |
| (Empty) |
| 1 #!/usr/bin/env python | |
| 2 | |
| 3 import sys, os, pwd, subprocess | |
| 4 | |
| 5 app_dir = '/opt/discourse' | |
| 6 | |
| 7 # HOME environment variable isn't reliable when called via sudo | |
| 8 home_dir = os.path.expanduser('~' + pwd.getpwuid(os.getuid()).pw_name) | |
| 9 | |
| 10 env = dict(os.environ) | |
| 11 env['RAILS_ENV'] = 'production' | |
| 12 | |
| 13 # See http://meta.discourse.org/t/tuning-ruby-and-rails-for-discourse/4126 | |
| 14 env['RUBY_GC_MALLOC_LIMIT'] = '90000000' | |
| 15 | |
| 16 def callRailsCommand(command): | |
| 17 subprocess.check_call(command, env=env, cwd=app_dir) | |
| 18 | |
| 19 def runInitCommands(): | |
| 20 service_path = '/etc/init.d/discourse' | |
| 21 | |
| 22 callRailsCommand(['bundle', 'install', '--deployment', '--without', 'test', '-
-without', 'development']) | |
| 23 callRailsCommand(['bundle', 'exec', 'rake', 'db:migrate']) | |
| 24 callRailsCommand(['bundle', 'exec', 'rake', 'assets:precompile']) | |
| 25 | |
| 26 if os.path.exists(service_path): | |
| 27 subprocess.check_call(['sudo', service_path, 'stop']) | |
| 28 | |
| 29 if os.path.exists(service_path): | |
| 30 subprocess.check_call(['sudo', service_path, 'start']) | |
| 31 | |
| 32 if __name__ == '__main__': | |
| 33 runInitCommands() | |
| OLD | NEW |