MCPcopy
hub / github.com/benoitc/gunicorn / start_gunicorn

Function start_gunicorn

benchmarks/run_benchmark.py:42–72  ·  view source on GitHub ↗

Start gunicorn server and return the process.

(worker_class, workers, threads, connections, bind, extra_args=None)

Source from the content-addressed store, hash-verified

40
41
42def start_gunicorn(worker_class, workers, threads, connections, bind, extra_args=None):
43 """Start gunicorn server and return the process."""
44 cmd = [
45 sys.executable, '-m', 'gunicorn',
46 '--worker-class', worker_class,
47 '--workers', str(workers),
48 '--threads', str(threads),
49 '--worker-connections', str(connections),
50 '--bind', bind,
51 '--access-logfile', '-',
52 '--error-logfile', '-',
53 '--log-level', 'warning',
54 APP_MODULE,
55 ]
56 if extra_args:
57 cmd.extend(extra_args)
58
59 env = os.environ.copy()
60 env['PYTHONPATH'] = str(BENCHMARK_DIR.parent)
61
62 proc = subprocess.Popen(
63 cmd,
64 cwd=BENCHMARK_DIR,
65 env=env,
66 stdout=subprocess.PIPE,
67 stderr=subprocess.PIPE,
68 )
69
70 # Wait for server to be ready
71 time.sleep(2)
72 return proc
73
74
75def stop_gunicorn(proc):

Callers 1

mainFunction · 0.70

Calls 1

copyMethod · 0.80

Tested by

no test coverage detected