forked from OpenShiftDemos/os-sample-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcmd_main.py
More file actions
36 lines (32 loc) · 1.29 KB
/
cmd_main.py
File metadata and controls
36 lines (32 loc) · 1.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
from __future__ import print_function
import argparse
import os
from wsgiref import simple_server
from jumpgate import wsgi
def main():
description = 'Start a single-threaded instance of jumpgate.'
parser = argparse.ArgumentParser(description=description)
parser.add_argument('--config',
default=os.environ.get('JUMPGATE_CONFIG'),
help='Jumpgate config location')
parser.add_argument('--host',
default='127.0.0.1',
help='host to listen on')
parser.add_argument('--port',
type=int,
default=5000,
help='port to listen on')
args = parser.parse_args()
httpd = simple_server.make_server(args.host,
args.port,
wsgi.make_api(args.config))
print("Starting server on (%s:%s)" % (args.host, args.port))
print("""
Warning: This is currently a test server for Jumpgate and not fit for
production since it is single-threaded. Use the WSGI application directly
along with a better wsgi server like gunicorn or uwsgi:
jumpgate.wsgi:make_api()""")
try:
httpd.serve_forever()
except KeyboardInterrupt:
print("Exiting...")