run_unicorn.py 849 B

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