chore: initial project setup with backend, frontend, and infrastructure
Add complete NexaPantry application structure including: - Docker Compose configuration with PostgreSQL, Redis, FastAPI backend, worker, frontend and Caddy - Environment configuration template with database, auth, and service settings - GitHub Actions CI workflow for backend/frontend linting, testing, auditing and Docker builds - AGPL-3.0 license and comprehensive README with setup, development, and security documentation - Backend
This commit is contained in:
31
backend/app/worker/main.py
Normal file
31
backend/app/worker/main.py
Normal file
@@ -0,0 +1,31 @@
|
||||
import logging
|
||||
import time
|
||||
|
||||
from app.core.config import get_settings
|
||||
from app.db.session import SessionLocal
|
||||
from app.services.notifications import create_expiry_notifications
|
||||
|
||||
logging.basicConfig(level=get_settings().log_level)
|
||||
logger = logging.getLogger("nexapantry.worker")
|
||||
|
||||
|
||||
def run_once() -> int:
|
||||
with SessionLocal() as db:
|
||||
return create_expiry_notifications(db)
|
||||
|
||||
|
||||
def main() -> None:
|
||||
interval = get_settings().daily_worker_interval_seconds
|
||||
logger.info("NexaPantry worker started")
|
||||
while True:
|
||||
try:
|
||||
count = run_once()
|
||||
logger.info("Created %s notification records", count)
|
||||
except Exception:
|
||||
logger.exception("Worker cycle failed")
|
||||
time.sleep(interval)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
Reference in New Issue
Block a user