run_unicorn.py 702 B

1234567891011121314151617181920
  1. import os
  2. import setup_util
  3. import helper
  4. from helper import Command
  5. def start(args, logfile, errfile):
  6. db_host = "DB_HOST={0}".format(args.database_host or 'localhost')
  7. start_server = db_host + " rvm 2.1.2 do bundle exec unicorn_rails -E production -c $TROOT/config/unicorn.rb"
  8. commands = [
  9. Command("sudo /usr/local/nginx/sbin/nginx -c $TROOT/config/nginx.conf", True),
  10. Command(start_server, False)
  11. ]
  12. return helper.run(commands, logfile, errfile, args.troot)
  13. def stop(logfile, errfile):
  14. helper.run([Command("sudo /usr/local/nginx/sbin/nginx -s stop -c $TROOT/config/nginx.conf", True)], logfile, errfile, os.environ['TROOT'])
  15. return helper.stop('unicorn', logfile, errfile)