From 65b3ee7593a2a884419e9f78bf117a5a22e035b7 Mon Sep 17 00:00:00 2001 From: Ben Zhang Date: Sun, 22 Sep 2024 19:30:31 -0700 Subject: [PATCH] Add DEPLOYMENT_ENVIRONMENT env var to runtime info (#8) This PR exposes the DEPLOYMENT_ENVIRONMENT variable in the runtime info. This is accessible via `GET /runtime-info`. --- src/main.py | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/main.py b/src/main.py index 8b03cd8..6fc7da5 100644 --- a/src/main.py +++ b/src/main.py @@ -57,18 +57,22 @@ def healthcheck(app: WATcloudFastAPI): scheduler.start() table_client = get_azure_table_client("signups", create_table_if_not_exists=True) directory_service = DirectoryService(logger=logger) +initial_runtime_info = { + "num_signups": 0, + "num_successful_confirms": 0, + "num_failed_confirms": 0, + "num_expired_signups": 0, + "num_successful_commits": 0, + "last_cleanup_time": time.time(), + "last_commit_time": time.time(), +} +if os.environ.get("DEPLOYMENT_ENVIRONMENT"): + initial_runtime_info["deployment_environment"] = os.environ["DEPLOYMENT_ENVIRONMENT"] + app = WATcloudFastAPI( logger=logger, lifespan=lifespan, - initial_runtime_info={ - "num_signups": 0, - "num_successful_confirms": 0, - "num_failed_confirms": 0, - "num_expired_signups": 0, - "num_successful_commits": 0, - "last_cleanup_time": time.time(), - "last_commit_time": time.time(), - }, + initial_runtime_info=initial_runtime_info, health_fns=[healthcheck], )