Update linting for pvcapid recent changes

This commit is contained in:
Joshua Boniface 2024-09-18 10:18:50 -04:00
parent a2e5df9f6d
commit ecb812ccac
2 changed files with 25 additions and 15 deletions

View File

@ -26,6 +26,6 @@ from os import path
current_dir = path.dirname(path.abspath(__file__)) current_dir = path.dirname(path.abspath(__file__))
sys.path.append(current_dir) sys.path.append(current_dir)
import pvcapid.Daemon # noqa: F401 import pvcapid.Daemon # noqa: F401, E402
pvcapid.Daemon.entrypoint() pvcapid.Daemon.entrypoint()

View File

@ -19,8 +19,6 @@
# #
############################################################################### ###############################################################################
import sys
import os
import subprocess import subprocess
from ssl import SSLContext, TLSVersion from ssl import SSLContext, TLSVersion
from distutils.util import strtobool as dustrtobool from distutils.util import strtobool as dustrtobool
@ -37,6 +35,7 @@ API_VERSION = 1.0
# Helper Functions # Helper Functions
########################################################## ##########################################################
def strtobool(stringv): def strtobool(stringv):
if stringv is None: if stringv is None:
return False return False
@ -62,6 +61,7 @@ config["daemon_version"] = version
# Flask App Creation for Gunicorn # Flask App Creation for Gunicorn
########################################################## ##########################################################
def create_app(): def create_app():
""" """
Create and return the Flask app and SSL context if necessary. Create and return the Flask app and SSL context if necessary.
@ -101,8 +101,9 @@ def create_app():
# Entrypoint # Entrypoint
########################################################## ##########################################################
def entrypoint(): def entrypoint():
if config['debug']: if config["debug"]:
app = create_app() app = create_app()
if config["api_ssl_enabled"]: if config["api_ssl_enabled"]:
@ -124,21 +125,30 @@ def entrypoint():
else: else:
# Build the command to run Gunicorn # Build the command to run Gunicorn
gunicorn_cmd = [ gunicorn_cmd = [
'gunicorn', "gunicorn",
'--workers', '1', "--workers",
'--threads', '8', "1",
'--timeout', '86400', "--threads",
'--bind', '{}:{}'.format(config["api_listen_address"], config["api_listen_port"]), "8",
'pvcapid.Daemon:create_app()', "--timeout",
'--log-level', 'info', "86400",
'--access-logfile', '-', "--bind",
'--error-logfile', '-', "{}:{}".format(config["api_listen_address"], config["api_listen_port"]),
"pvcapid.Daemon:create_app()",
"--log-level",
"info",
"--access-logfile",
"-",
"--error-logfile",
"-",
] ]
if config["api_ssl_enabled"]: if config["api_ssl_enabled"]:
gunicorn_cmd += [ gunicorn_cmd += [
'--certfile', config["api_ssl_cert_file"], "--certfile",
'--keyfile', config["api_ssl_key_file"] config["api_ssl_cert_file"],
"--keyfile",
config["api_ssl_key_file"],
] ]
# Run Gunicorn # Run Gunicorn