|
@@ -1,28 +1,32 @@
|
|
import subprocess
|
|
import subprocess
|
|
-import multiprocessing
|
|
|
|
-import sys
|
|
|
|
import setup_util
|
|
import setup_util
|
|
|
|
+import multiprocessing
|
|
import os
|
|
import os
|
|
-from os.path import expanduser
|
|
|
|
|
|
|
|
-home = expanduser("~")
|
|
|
|
|
|
+bin_dir = os.path.expanduser('~/FrameworkBenchmarks/installs/py2/bin')
|
|
|
|
+NCPU = multiprocessing.cpu_count()
|
|
|
|
+
|
|
|
|
+proc = None
|
|
|
|
+
|
|
|
|
|
|
def start(args):
|
|
def start(args):
|
|
- setup_util.replace_text("django/hello/hello/settings.py", "HOST': '.*'", "HOST': '" + args.database_host + "'")
|
|
|
|
- setup_util.replace_text("django/hello/hello/settings.py", "\/home\/ubuntu", home)
|
|
|
|
- subprocess.Popen("gunicorn hello.wsgi:application --worker-class=meinheld.gmeinheld.MeinheldWorker -b 0.0.0.0:8080 -w " +
|
|
|
|
- str((multiprocessing.cpu_count() * 3)) + " --log-level=critical", shell=True, cwd="django/hello")
|
|
|
|
- return 0
|
|
|
|
|
|
+ setup_util.replace_text("django/hello/hello/settings.py", "HOST': '.*'", "HOST': '" + args.database_host + "'")
|
|
|
|
+ setup_util.replace_text("django/hello/hello/settings.py", "\/home\/ubuntu", home)
|
|
|
|
+ proc = subprocess.Popen([
|
|
|
|
+ bin_dir + "/gunicorn",
|
|
|
|
+ "hello.wsgi:application",
|
|
|
|
+ "-k", "meinheld.gmeinheld.MeinheldWorker",
|
|
|
|
+ "-b", "0.0.0.0:8080",
|
|
|
|
+ '-w', str(NCPU*2),
|
|
|
|
+ "--log-level=critical"],
|
|
|
|
+ cwd="django/hello")
|
|
|
|
+ return 0
|
|
|
|
|
|
def stop():
|
|
def stop():
|
|
- p = subprocess.Popen(['ps', 'aux'], stdout=subprocess.PIPE)
|
|
|
|
- out, err = p.communicate()
|
|
|
|
- for line in out.splitlines():
|
|
|
|
- if 'gunicorn' in line:
|
|
|
|
- try:
|
|
|
|
- pid = int(line.split(None, 2)[1])
|
|
|
|
- os.kill(pid, 9)
|
|
|
|
- except OSError:
|
|
|
|
- pass
|
|
|
|
-
|
|
|
|
- return 0
|
|
|
|
|
|
+ global proc
|
|
|
|
+ if proc is None:
|
|
|
|
+ return 0
|
|
|
|
+ proc.terminate()
|
|
|
|
+ proc.wait()
|
|
|
|
+ proc = None
|
|
|
|
+ return 0
|