eaabebbceb
- MAC地址格式统一为小写 xxxx-xxxx-xxxx,支持三种格式输入 - 更换设备MAC时自动清理OLT新发现列表中的冲突ONU记录 - 设备编辑新增场所类型字段(手动输入),区域改为下拉快速填充 - 编辑/更换设备时自动移除new_devices中同MAC的待入库记录 - 新增登录过期自动跳转(401拦截 + 过期提示) - 新增关于页面(/about),支持Markdown渲染,管理员可在设置中编辑内容 - 新增device_status_history每日自动清理任务(保留30天) - 更新README.md和about.md
44 lines
1.5 KiB
Python
44 lines
1.5 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'},
|
|
},
|
|
'cleanup-status-history': {
|
|
'task': 'app.tasks.check_tasks.cleanup_status_history',
|
|
'schedule': crontab(hour=3, minute=0), # 每天凌晨 3:00
|
|
'options': {'queue': 'h3c_onu_ms'},
|
|
},
|
|
},
|
|
)
|