44 lines
1.3 KiB
Python
44 lines
1.3 KiB
Python
"""
|
|
Main entry point for alert processor jobs when run as modules.
|
|
|
|
This file makes the jobs package executable as a module:
|
|
`python -m app.jobs.priority_recalculation`
|
|
"""
|
|
|
|
import asyncio
|
|
import sys
|
|
import os
|
|
from pathlib import Path
|
|
|
|
# Add the app directory to Python path
|
|
sys.path.insert(0, str(Path(__file__).parent.parent))
|
|
sys.path.insert(0, str(Path(__file__).parent.parent.parent.parent / "shared"))
|
|
|
|
from app.jobs.priority_recalculation import run_priority_recalculation_job
|
|
from app.config import AlertProcessorConfig
|
|
from shared.database.base import create_database_manager
|
|
from app.core.cache import get_redis_client
|
|
|
|
|
|
async def main():
|
|
"""Main entry point for the priority recalculation job."""
|
|
# Initialize services
|
|
config = AlertProcessorConfig()
|
|
db_manager = create_database_manager(config.DATABASE_URL, "alert-processor")
|
|
redis_client = await get_redis_client()
|
|
|
|
try:
|
|
# Run the priority recalculation job
|
|
results = await run_priority_recalculation_job(
|
|
config=config,
|
|
db_manager=db_manager,
|
|
redis_client=redis_client
|
|
)
|
|
print(f"Priority recalculation completed: {results}")
|
|
except Exception as e:
|
|
print(f"Error running priority recalculation job: {e}", file=sys.stderr)
|
|
sys.exit(1)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
asyncio.run(main()) |