Move startup code to an entrypoint function

Prevents further issues with startup.
This commit is contained in:
Joshua Boniface 2021-05-30 00:18:04 -04:00
parent 25f80a4478
commit 73407e245f
2 changed files with 27 additions and 24 deletions

View File

@ -20,3 +20,5 @@
############################################################################### ###############################################################################
import pvcapid.Daemon # noqa: F401 import pvcapid.Daemon # noqa: F401
pvcapid.Daemon.entrypoint()

View File

@ -107,30 +107,31 @@ except Exception as e:
# Entrypoint # Entrypoint
########################################################## ##########################################################
import pvcapid.flaskapi as pvc_api # noqa: E402 def entrypoint():
import pvcapid.flaskapi as pvc_api # noqa: E402
if config['ssl_enabled']: if config['ssl_enabled']:
context = (config['ssl_cert_file'], config['ssl_key_file']) context = (config['ssl_cert_file'], config['ssl_key_file'])
else: else:
context = None context = None
# Print our startup messages # Print our startup messages
print('') print('')
print('|--------------------------------------------------|') print('|--------------------------------------------------|')
print('| ######## ## ## ###### |') print('| ######## ## ## ###### |')
print('| ## ## ## ## ## ## |') print('| ## ## ## ## ## ## |')
print('| ## ## ## ## ## |') print('| ## ## ## ## ## |')
print('| ######## ## ## ## |') print('| ######## ## ## ## |')
print('| ## ## ## ## |') print('| ## ## ## ## |')
print('| ## ## ## ## ## |') print('| ## ## ## ## ## |')
print('| ## ### ###### |') print('| ## ### ###### |')
print('|--------------------------------------------------|') print('|--------------------------------------------------|')
print('| Parallel Virtual Cluster API daemon v{0: <11} |'.format(version)) print('| Parallel Virtual Cluster API daemon v{0: <11} |'.format(version))
print('| API version: v{0: <34} |'.format(API_VERSION)) print('| API version: v{0: <34} |'.format(API_VERSION))
print('| Listen: {0: <40} |'.format('{}:{}'.format(config['listen_address'], config['listen_port']))) print('| Listen: {0: <40} |'.format('{}:{}'.format(config['listen_address'], config['listen_port'])))
print('| SSL: {0: <43} |'.format(str(config['ssl_enabled']))) print('| SSL: {0: <43} |'.format(str(config['ssl_enabled'])))
print('| Authentication: {0: <32} |'.format(str(config['auth_enabled']))) print('| Authentication: {0: <32} |'.format(str(config['auth_enabled'])))
print('|--------------------------------------------------|') print('|--------------------------------------------------|')
print('') print('')
pvc_api.app.run(config['listen_address'], config['listen_port'], threaded=True, ssl_context=context) pvc_api.app.run(config['listen_address'], config['listen_port'], threaded=True, ssl_context=context)