Skip to content

Commit f2ddc22

Browse files
committed
✨ Add application factory name to settings and update app factory logic
1 parent 042f6d0 commit f2ddc22

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

services/web/server/src/simcore_service_webserver/application_settings.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import logging
22
from functools import cached_property
3-
from typing import Annotated, Any, Final
3+
from typing import Annotated, Any, Final, Literal
44

55
from aiohttp import web
66
from common_library.basic_types import DEFAULT_FACTORY
@@ -95,6 +95,13 @@ class ApplicationSettings(BaseApplicationSettings, MixinLoggingSettings):
9595
Field(None, description="Stack name defined upon deploy (see main Makefile)"),
9696
]
9797

98+
WEBSERVER_APP_FACTORY_NAME: Annotated[
99+
Literal["WEBSERVER_FULL_APP_FACTORY", "WEBSERVER_AUTHZ_APP_FACTORY"],
100+
Field(
101+
description="Application factory to be lauched by the guvicorn server",
102+
),
103+
] = "WEBSERVER_FULL_APP_FACTORY"
104+
98105
WEBSERVER_DEV_FEATURES_ENABLED: Annotated[
99106
bool,
100107
Field(

services/web/server/src/simcore_service_webserver/cli.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,14 +66,22 @@ def _setup_app_from_settings(
6666
async def app_factory() -> web.Application:
6767
"""Created to launch app from gunicorn (see docker/boot.sh)"""
6868
app_settings = ApplicationSettings.create_from_envs()
69-
assert app_settings.SC_BUILD_TARGET # nosec
7069

7170
_logger.info(
7271
"Application settings: %s",
7372
json_dumps(app_settings, indent=2, sort_keys=True),
7473
)
7574

76-
app, _ = _setup_app_from_settings(app_settings)
75+
_logger.info(
76+
"Using application factory: %s", app_settings.WEBSERVER_APP_FACTORY_NAME
77+
)
78+
79+
if app_settings.WEBSERVER_APP_FACTORY_NAME == "WEBSERVER_AUTHZ_APP_FACTORY":
80+
from .application import create_application_authz
81+
82+
app = create_application_authz()
83+
else:
84+
app, _ = _setup_app_from_settings(app_settings)
7785

7886
return app
7987

0 commit comments

Comments
 (0)