f1f8518985
feat(auth): 添加用户权限获取接口并完善JWT令牌角色信息 - 在JWT令牌中添加用户角色信息 - 新增get_my_permissions接口用于获取当前用户权限码列表 - 重构认证回调逻辑,增加错误日志记录 - 更新用户信息获取接口使用Authorization头验证 ```
39 lines
1.3 KiB
Python
39 lines
1.3 KiB
Python
"""Celery 配置"""
|
|
from celery import Celery
|
|
from celery.schedules import crontab
|
|
from app.core.config import settings
|
|
|
|
celery_app = Celery(
|
|
"h3c_onu_ms",
|
|
broker=settings.REDIS_URL,
|
|
backend=settings.REDIS_URL
|
|
)
|
|
|
|
celery_app.conf.update(
|
|
task_serializer='json',
|
|
result_serializer='json',
|
|
accept_content=['json'],
|
|
timezone='Asia/Shanghai',
|
|
enable_utc=True,
|
|
# 使用专属队列,避免与同 Redis 上的其他 Celery 项目抢任务
|
|
task_default_queue='h3c_onu_ms',
|
|
beat_schedule={
|
|
# 每5分钟触发一次(最小间隔),任务内部根据配置的间隔自行节流
|
|
'check-devices-scheduler': {
|
|
'task': 'app.tasks.check_tasks.check_all_devices',
|
|
'schedule': 300,
|
|
'options': {'queue': 'h3c_onu_ms'},
|
|
},
|
|
'aggregate-daily-snapshot': {
|
|
'task': 'app.tasks.check_tasks.aggregate_daily_snapshot',
|
|
'schedule': crontab(hour=1, minute=0), # 每天凌晨 1:00
|
|
'options': {'queue': 'h3c_onu_ms'},
|
|
},
|
|
'cleanup-audit-logs': {
|
|
'task': 'app.tasks.audit_tasks.cleanup_audit_logs_task',
|
|
'schedule': crontab(hour=2, minute=0), # 每天凌晨 2:00
|
|
'options': {'queue': 'h3c_onu_ms'},
|
|
},
|
|
},
|
|
)
|