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
pvcapid.Daemon.entrypoint()

View File

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