task_app.py 837 B

1234567891011121314151617181920212223242526272829
  1. from quart import Quart
  2. from applications.config import aliyun_log_config
  3. from applications.database import mysql_manager
  4. from applications.service import LogService
  5. from routes import server_routes
  6. log_service = LogService(**aliyun_log_config)
  7. app = Quart(__name__)
  8. routes = server_routes(mysql_manager, log_service)
  9. app.register_blueprint(routes)
  10. @app.before_serving
  11. async def startup():
  12. print("Starting application...")
  13. await mysql_manager.init_pools()
  14. print("Mysql pools init successfully")
  15. await log_service.start()
  16. print("aliyun log service init successfully")
  17. @app.after_serving
  18. async def shutdown():
  19. print("Shutting down application...")
  20. await mysql_manager.close_pools()
  21. print("Mysql pools close successfully")
  22. await log_service.stop()
  23. print("aliyun log service stop successfully")