Override-based compose, profiles in .env, README

This commit is contained in:
hh committed 2026-09-09 00:18:15 +02:00
1 parent 1f416dbe60
commit ac0ccf47e5
13 files changed
+131 -88

No files matched your search

@@ -1,5 +1,6 @@
import asyncio
import contextlib
import signal
import anyio
import uvloop
@@ -11,8 +12,15 @@ import uvloop
setup_logging()
SCAN_INTERVAL = 10
async def runner() -> None:
stop = asyncio.Event()
loop = asyncio.get_running_loop()
for sig in (signal.SIGINT, signal.SIGTERM):
loop.add_signal_handler(sig, stop.set)
{% if database != 'none' %} await init_db()
{% endif %} sessions_dir = anyio.Path("sessions")
@@ -22,7 +30,7 @@ async def runner() -> None:
clients: dict[int, PyroClient] = {}
try:
while True:
while not stop.is_set():
current = {path.name async for path in sessions_dir.glob("*.session")}
for session_file in current - started:
@@ -43,7 +51,8 @@ async def runner() -> None:
if me:
clients[me.id] = client
await asyncio.sleep(10)
with contextlib.suppress(TimeoutError):
await asyncio.wait_for(stop.wait(), SCAN_INTERVAL)
finally:
for client in clients.values():
with contextlib.suppress(Exception):
@@ -55,8 +64,5 @@ def main() -> None:
uvloop.install()
logger.info("Starting...")
with contextlib.suppress(KeyboardInterrupt):
asyncio.run(runner())
asyncio.run(runner())
logger.info("[red]Stopped.[/]")