From 4f25c55efc73ed9134111436ab558a1fba3e12ee Mon Sep 17 00:00:00 2001 From: "Joshua M. Boniface" Date: Sat, 8 Feb 2020 20:27:45 -0500 Subject: [PATCH] Fix startup of API daemon References #79 --- api-daemon/pvcapid.py | 2 +- api-daemon/pvcapid/{api.py => Daemon.py} | 41 ++++++++++++------------ 2 files changed, 21 insertions(+), 22 deletions(-) rename api-daemon/pvcapid/{api.py => Daemon.py} (99%) diff --git a/api-daemon/pvcapid.py b/api-daemon/pvcapid.py index 79a852c4..2caaf148 100755 --- a/api-daemon/pvcapid.py +++ b/api-daemon/pvcapid.py @@ -20,4 +20,4 @@ # ############################################################################### -import pvcapid.api +import pvcapid.Daemon diff --git a/api-daemon/pvcapid/api.py b/api-daemon/pvcapid/Daemon.py similarity index 99% rename from api-daemon/pvcapid/api.py rename to api-daemon/pvcapid/Daemon.py index 043b26f6..bd088e4e 100755 --- a/api-daemon/pvcapid/api.py +++ b/api-daemon/pvcapid/Daemon.py @@ -1,6 +1,6 @@ #!/usr/bin/env python3 -# api.py - PVC HTTP API interface +# Daemon.py - PVC HTTP API daemon # Part of the Parallel Virtual Cluster (PVC) system # # Copyright (C) 2018-2020 Joshua M. Boniface @@ -5612,25 +5612,24 @@ api.add_resource(API_Provisioner_Status_Element, '/provisioner/status/' ########################################################## # Entrypoint ########################################################## -if __name__ == '__main__': - if config['debug']: - # Run in Flask standard mode - app.run(config['listen_address'], config['listen_port']) +if config['debug']: + # Run in Flask standard mode + 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: - 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: - # Run the ?WSGI server without SSL - http_server = gevent.pywsgi.WSGIServer( - (config['listen_address'], config['listen_port']), - app - ) + # 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'])) - http_server.serve_forever() + 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()