setup.py 723 B

1234567891011121314151617181920212223242526
  1. import subprocess
  2. import json
  3. import os
  4. def start(args, logfile, errfile):
  5. conf = {
  6. 'database_host' : args.database_host,
  7. 'workers' : args.max_threads,
  8. }
  9. with open(args.troot + '/app.conf', 'w') as f:
  10. f.write(json.dumps(conf))
  11. try:
  12. # os.environ["MOJO_MODE"] = "production"
  13. subprocess.Popen("carton exec hypnotoad $TROOT/app.pl", shell=True, cwd="mojolicious", stderr=errfile, stdout=logfile)
  14. return 0
  15. except subprocess.CalledProcessError:
  16. return 1
  17. def stop(logfile, errfile):
  18. try:
  19. subprocess.call("carton exec hypnotoad -s $TROOT/app.pl", shell=True, cwd="mojolicious", stderr=errfile, stdout=logfile)
  20. return 0
  21. except subprocess.CalledProcessError:
  22. return 1