Fix startup of API daemon

References #79
This commit is contained in:
Joshua Boniface 2020-02-08 20:27:45 -05:00
parent 3532dcc11f
commit 4f25c55efc
2 changed files with 21 additions and 22 deletions

View File

@ -20,4 +20,4 @@
# #
############################################################################### ###############################################################################
import pvcapid.api import pvcapid.Daemon

View File

@ -1,6 +1,6 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
# api.py - PVC HTTP API interface # Daemon.py - PVC HTTP API daemon
# Part of the Parallel Virtual Cluster (PVC) system # Part of the Parallel Virtual Cluster (PVC) system
# #
# Copyright (C) 2018-2020 Joshua M. Boniface <joshua@boniface.me> # Copyright (C) 2018-2020 Joshua M. Boniface <joshua@boniface.me>
@ -5612,25 +5612,24 @@ api.add_resource(API_Provisioner_Status_Element, '/provisioner/status/<task_id>'
########################################################## ##########################################################
# Entrypoint # Entrypoint
########################################################## ##########################################################
if __name__ == '__main__': if config['debug']:
if config['debug']: # Run in Flask standard mode
# Run in Flask standard mode app.run(config['listen_address'], config['listen_port'])
app.run(config['listen_address'], config['listen_port']) else:
if config['ssl_enabled']:
# Run the WSGI server with SSL
http_server = gevent.pywsgi.WSGIServer(
(config['listen_address'], config['listen_port']),
app,
keyfile=config['ssl_key_file'],
certfile=config['ssl_cert_file']
)
else: else:
if config['ssl_enabled']: # Run the ?WSGI server without SSL
# Run the WSGI server with SSL http_server = gevent.pywsgi.WSGIServer(
http_server = gevent.pywsgi.WSGIServer( (config['listen_address'], config['listen_port']),
(config['listen_address'], config['listen_port']), app
app, )
keyfile=config['ssl_key_file'],
certfile=config['ssl_cert_file']
)
else:
# Run the ?WSGI server without SSL
http_server = gevent.pywsgi.WSGIServer(
(config['listen_address'], config['listen_port']),
app
)
print('Starting PyWSGI server at {}:{} with SSL={}, Authentication={}'.format(config['listen_address'], config['listen_port'], config['ssl_enabled'], config['auth_enabled'])) print('Starting PyWSGI server at {}:{} with SSL={}, Authentication={}'.format(config['listen_address'], config['listen_port'], config['ssl_enabled'], config['auth_enabled']))
http_server.serve_forever() http_server.serve_forever()