From 7a2717542309adacc91d6e424126b85eba34fa6f Mon Sep 17 00:00:00 2001 From: Xevion Date: Fri, 1 Nov 2024 16:56:39 -0500 Subject: [PATCH] Remove development mode check for ip_pool generation I just wanna see it run on the production serve once, I'll remove all of this later. --- CHANGELOG.md | 6 ++++++ backend/linkpulse/app.py | 13 ++++++------- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 80db896..c1db103 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [Unreleased] + +### Changed + +- A development mode check for the `app.state.ip_pool`'s initialization (caused application failure in production only) + ## [0.2.0] - 2024-11-01 ### Added diff --git a/backend/linkpulse/app.py b/backend/linkpulse/app.py index dd700c7..0473834 100644 --- a/backend/linkpulse/app.py +++ b/backend/linkpulse/app.py @@ -67,13 +67,12 @@ scheduler.add_job(flush_ips, IntervalTrigger(seconds=5)) @asynccontextmanager async def lifespan(_: FastAPI) -> AsyncIterator[None]: - if is_development: - # 42 is the answer to everything - random.seed(42) - # Generate a pool of random IP addresses - app.state.ip_pool = [ - ".".join(str(random.randint(0, 255)) for _ in range(4)) for _ in range(50) - ] + # Originally, this was used to generate a pool of random IP addresses so we could demo a changing list. + # Now, this isn't necessary, but I just wanna test it for now. It'll be removed pretty soon. + random.seed(42) # 42 is the answer to everything + app.state.ip_pool = [ + ".".join(str(random.randint(0, 255)) for _ in range(4)) for _ in range(50) + ] # Connect to database, ensure specific tables exist db.connect()