diff --git a/backend/backend/__main__.py b/backend/backend/__main__.py index 1e50d2c..e9521d0 100644 --- a/backend/backend/__main__.py +++ b/backend/backend/__main__.py @@ -5,9 +5,10 @@ from hypercorn.asyncio import serve from .web import app from .pag import Runner +from .settings import settings config = Config() -config.bind = ["0.0.0.0:8000"] +config.bind = [settings.bind] pag_runner = Runner() pag_runner.start() diff --git a/backend/backend/arbiter.py b/backend/backend/arbiter.py index 2ad710e..8d9a576 100644 --- a/backend/backend/arbiter.py +++ b/backend/backend/arbiter.py @@ -49,7 +49,7 @@ class ClientState: self.inactivity_task = asyncio.create_task(self.deactivator()) async def deactivator(self): - await asyncio.sleep(settings.CLIENT_IDLE_TIMEOUT) + await asyncio.sleep(settings.client_idle_timeout) self.is_active = False self.inactivity_task = None @@ -119,7 +119,7 @@ class Arbiter: self.state.mode = self.current_mode.name self.update_next_mode() self.modeswitch_time = datetime.now() + timedelta( - seconds=settings.ARBITER_MODE_SWITCH_CYCLE + seconds=settings.arbiter_mode_switch_cycle ) if self.current_mode_task: @@ -135,7 +135,7 @@ class Arbiter: ).total_seconds() await asyncio.gather( - asyncio.sleep(settings.ARBITER_TICK_CYCLE), + asyncio.sleep(settings.arbiter_tick_cycle), *[ socket.send_json( { @@ -155,7 +155,7 @@ arbiter = Arbiter() @arbiter.mode("democracy", allow_multitouch=False) async def _(get_input: InputGetter, set_output: OutputSetter): while True: - await asyncio.sleep(settings.DEMOCRACY_VOTE_CYCLE) + await asyncio.sleep(settings.democracy_vote_cycle) vote = {button: 0 for button in Button} vote["none"] = 0 diff --git a/backend/backend/settings.py b/backend/backend/settings.py index 11538e4..7d9f0f5 100644 --- a/backend/backend/settings.py +++ b/backend/backend/settings.py @@ -2,12 +2,14 @@ from pydantic import BaseSettings class Settings(BaseSettings): - CLIENT_IDLE_TIMEOUT: float = 10 + bind: str = "0.0.0.0:8000" - ARBITER_TICK_CYCLE: float = 0.1 - ARBITER_MODE_SWITCH_CYCLE: float = 10 + client_idle_timeout: float = 10 - DEMOCRACY_VOTE_CYCLE: float = 0.25 + arbiter_tick_cycle: float = 0.1 + arbiter_mode_switch_cycle: float = 10 + + democracy_vote_cycle: float = 0.25 settings = Settings()