setup.py 854 B

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