feat(scheduler): implement scheduler service for background tasks and credit refills; add endpoints for admin control
This commit is contained in:
@@ -7,6 +7,7 @@ from flask_jwt_extended import JWTManager
|
||||
|
||||
from app.database import init_db
|
||||
from app.services.auth_service import AuthService
|
||||
from app.services.scheduler_service import scheduler_service
|
||||
|
||||
# Global auth service instance
|
||||
auth_service = AuthService()
|
||||
@@ -60,10 +61,20 @@ def create_app():
|
||||
# Initialize authentication service with app
|
||||
auth_service.init_app(app)
|
||||
|
||||
# Start scheduler for background tasks
|
||||
scheduler_service.start()
|
||||
|
||||
# Register blueprints
|
||||
from app.routes import auth, main
|
||||
|
||||
app.register_blueprint(main.bp, url_prefix="/api")
|
||||
app.register_blueprint(auth.bp, url_prefix="/api/auth")
|
||||
|
||||
# Shutdown scheduler when app is torn down
|
||||
@app.teardown_appcontext
|
||||
def shutdown_scheduler(exception):
|
||||
"""Stop scheduler when app context is torn down."""
|
||||
if exception:
|
||||
scheduler_service.stop()
|
||||
|
||||
return app
|
||||
|
||||
Reference in New Issue
Block a user