{% extends "base.html" %} {% block title %}AgomTradePro - {{ page_title }}{% endblock %} {% block content %}

{{ page_title }}

把数据库中的 PeriodicTask 配置和 Celery 运行态放在一个视图里,便于确认默认计划任务是否已初始化、是否启用,以及最近有没有失败。

{% csrf_token %}
PeriodicTask Admin 执行记录 Admin
计划任务总数
{{ summary.total_tasks }}
已启用
{{ summary.enabled_tasks }}
已禁用
{{ summary.disabled_tasks }}
Crontab
{{ summary.crontab_tasks }}
Interval
{{ summary.interval_tasks }}
One-off
{{ summary.one_off_tasks }}

PeriodicTask 目录

{% for task in periodic_tasks %} {% empty %} {% endfor %}
任务 调度 启用 最近运行 最近执行结果 失败(24h)
{{ task.name }}
{{ task.task_path }}
{% if task.description %}
{{ task.description }}
{% endif %}
kwargs: {{ task.kwargs_preview }}
{{ task.schedule_display }}
{{ task.schedule_type }}{% if task.queue %} | queue={{ task.queue }}{% endif %}
{% if task.enabled %} enabled {% else %} disabled {% endif %}
run count: {{ task.total_run_count }}
{% if task.last_run_at %}
{{ task.last_run_at|date:"Y-m-d H:i" }}
{% else %}
尚未运行
{% endif %}
{% if task.last_execution_status == "success" %} success {% elif task.last_execution_status == "failure" or task.last_execution_status == "timeout" %} {{ task.last_execution_status }} {% elif task.last_execution_status %} {{ task.last_execution_status }} {% else %} no record {% endif %} {% if task.last_execution_at %}
{{ task.last_execution_at|date:"Y-m-d H:i" }}
{% endif %} {% if task.last_runtime_seconds %}
runtime {{ task.last_runtime_seconds|floatformat:2 }}s
{% endif %}
{% if task.recent_failure_count > 0 %} {{ task.recent_failure_count }} {% else %} 0 {% endif %}
当前数据库中还没有 PeriodicTask。可以先点击上方的一键初始化。

Celery 运行态

健康状态 {% if health.is_healthy %}Healthy{% else %}Degraded{% endif %}
Worker 数量 {{ health.active_workers|length }}
活跃任务 {{ health.active_tasks_count }}
待处理 / 已调度 {{ health.pending_tasks_count }} / {{ health.scheduled_tasks_count }}

最近失败任务

    {% for failure in recent_failures.items %}
  • {{ failure.task_name }}
    task_id={{ failure.task_id }}
    status={{ failure.status }} | retries={{ failure.retries }}
    {% if failure.finished_at %}
    finished={{ failure.finished_at }}
    {% endif %}
  • {% empty %}
  • 最近 24 小时没有失败记录。
  • {% endfor %}

数据库入口

周期任务本身存放在 django_celery_beat 的数据库表里,页面这里只做统一观测与初始化入口;细粒度编辑仍可直接走 Django Admin。

{% endblock %}