in src/main.py [0:0]
def __call__(self, host: str = DEFAULT_HOST, port: int = DEFAULT_PORT,
gunicorn: bool = False, workers: int | None = None,
swagger: bool = False,
swagger_prefix: str = DEFAULT_SWAGGER_PREFIX):
from onprem.app import OnPremApiBuilder
self._host = host
self._port = port
if not gunicorn and workers:
_LOG.warning(
'--workers is ignored because you are not running Gunicorn'
)
os.environ[Env.SERVICE_MODE] = 'docker'
stage = 'dev' # todo get from somewhere
app = OnPremApiBuilder().build(stage)
if swagger:
self._init_swagger(app, swagger_prefix, stage)
if gunicorn:
workers = workers or DEFAULT_NUMBER_OF_WORKERS
from onprem.app_gunicorn import CustodianGunicornApplication
options = {
'bind': f'{host}:{port}',
'workers': workers,
}
CustodianGunicornApplication(app, options).run()
else:
app.run(host=host, port=port)