feat: Add scheduler and fix some types
All checks were successful
Build Docker / BuildImage (push) Successful in 58s

This commit is contained in:
2025-07-24 16:33:31 +10:00
parent 3ddf7c5dfe
commit 1ac41d5582
5 changed files with 49 additions and 9 deletions

28
main.py
View File

@@ -4,6 +4,9 @@ import server
from gunicorn.app.base import BaseApplication
import os
import dotenv
import threading
import time
import domains
class GunicornApp(BaseApplication):
@@ -14,18 +17,35 @@ class GunicornApp(BaseApplication):
def load_config(self):
for key, value in self.options.items():
if key in self.cfg.settings and value is not None:
self.cfg.set(key.lower(), value)
if key in self.cfg.settings and value is not None: # type: ignore
self.cfg.set(key.lower(), value) # type: ignore
def load(self):
return self.application
def run_expiry_checker():
"""
Background function to run notify_expiries every 2 minutes.
"""
while True:
try:
print("Running expiry check...")
domains.notify_expiries()
print("Expiry check completed.")
except Exception as e:
print(f"Error in expiry checker: {e}")
# Wait 2 minutes (120 seconds)
time.sleep(120)
if __name__ == '__main__':
dotenv.load_dotenv()
# Start the background expiry checker
expiry_thread = threading.Thread(target=run_expiry_checker, daemon=True)
expiry_thread.start()
print("Started background expiry checker thread")
workers = os.getenv('WORKERS', 1)
threads = os.getenv('THREADS', 2)
workers = int(workers)