|
|
@ -31,11 +31,13 @@ def sigterm_handler(_signo, _stack_frame):
|
|
|
|
def main():
|
|
|
|
def main():
|
|
|
|
global datastore
|
|
|
|
global datastore
|
|
|
|
global app
|
|
|
|
global app
|
|
|
|
ssl_mode = False
|
|
|
|
|
|
|
|
|
|
|
|
datastore_path = None
|
|
|
|
|
|
|
|
do_cleanup = False
|
|
|
|
host = ''
|
|
|
|
host = ''
|
|
|
|
|
|
|
|
ipv6_enabled = False
|
|
|
|
port = os.environ.get('PORT') or 5000
|
|
|
|
port = os.environ.get('PORT') or 5000
|
|
|
|
do_cleanup = False
|
|
|
|
ssl_mode = False
|
|
|
|
datastore_path = None
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# On Windows, create and use a default path.
|
|
|
|
# On Windows, create and use a default path.
|
|
|
|
if os.name == 'nt':
|
|
|
|
if os.name == 'nt':
|
|
|
@ -46,7 +48,7 @@ def main():
|
|
|
|
datastore_path = os.path.join(os.getcwd(), "../datastore")
|
|
|
|
datastore_path = os.path.join(os.getcwd(), "../datastore")
|
|
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
opts, args = getopt.getopt(sys.argv[1:], "Ccsd:h:p:", "port")
|
|
|
|
opts, args = getopt.getopt(sys.argv[1:], "6Ccsd:h:p:", "port")
|
|
|
|
except getopt.GetoptError:
|
|
|
|
except getopt.GetoptError:
|
|
|
|
print('backend.py -s SSL enable -h [host] -p [port] -d [datastore path]')
|
|
|
|
print('backend.py -s SSL enable -h [host] -p [port] -d [datastore path]')
|
|
|
|
sys.exit(2)
|
|
|
|
sys.exit(2)
|
|
|
@ -66,6 +68,10 @@ def main():
|
|
|
|
if opt == '-d':
|
|
|
|
if opt == '-d':
|
|
|
|
datastore_path = arg
|
|
|
|
datastore_path = arg
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if opt == '-6':
|
|
|
|
|
|
|
|
print ("Enabling IPv6 listen support")
|
|
|
|
|
|
|
|
ipv6_enabled = True
|
|
|
|
|
|
|
|
|
|
|
|
# Cleanup (remove text files that arent in the index)
|
|
|
|
# Cleanup (remove text files that arent in the index)
|
|
|
|
if opt == '-c':
|
|
|
|
if opt == '-c':
|
|
|
|
do_cleanup = True
|
|
|
|
do_cleanup = True
|
|
|
@ -133,13 +139,15 @@ def main():
|
|
|
|
from werkzeug.middleware.proxy_fix import ProxyFix
|
|
|
|
from werkzeug.middleware.proxy_fix import ProxyFix
|
|
|
|
app.wsgi_app = ProxyFix(app.wsgi_app, x_prefix=1, x_host=1)
|
|
|
|
app.wsgi_app = ProxyFix(app.wsgi_app, x_prefix=1, x_host=1)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
s_type = socket.AF_INET6 if ipv6_enabled else socket.AF_INET
|
|
|
|
|
|
|
|
|
|
|
|
if ssl_mode:
|
|
|
|
if ssl_mode:
|
|
|
|
# @todo finalise SSL config, but this should get you in the right direction if you need it.
|
|
|
|
# @todo finalise SSL config, but this should get you in the right direction if you need it.
|
|
|
|
eventlet.wsgi.server(eventlet.wrap_ssl(eventlet.listen((host, port), socket.AF_INET6),
|
|
|
|
eventlet.wsgi.server(eventlet.wrap_ssl(eventlet.listen((host, port), s_type),
|
|
|
|
certfile='cert.pem',
|
|
|
|
certfile='cert.pem',
|
|
|
|
keyfile='privkey.pem',
|
|
|
|
keyfile='privkey.pem',
|
|
|
|
server_side=True), app)
|
|
|
|
server_side=True), app)
|
|
|
|
|
|
|
|
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
eventlet.wsgi.server(eventlet.listen((host, int(port)), socket.AF_INET6), app)
|
|
|
|
eventlet.wsgi.server(eventlet.listen((host, int(port)), s_type), app)
|
|
|
|
|
|
|
|
|
|
|
|