Fix Docker apply crash and add safe profile test flow

Remove invalid _mirror_manager from daemon.json that prevented Docker from starting. Add 2-minute test apply with auto-rollback, final apply confirmation, emergency-restore CLI/UI, and post-restart Docker health checks.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-06-10 20:20:10 +03:30
parent 1c9d647787
commit 63d0699cdd
20 changed files with 635 additions and 324 deletions
+75 -53
View File
@@ -1,53 +1,75 @@
{% extends "base.html" %}
{% from "macros.html" import guide_box %}
{% block title %}اعمال تنظیمات{% endblock %}
{% block content %}
<h2>اعمال پروفایل</h2>
{{ guide_box(guide, 'profiles') }}
{% if pending and not pending.confirmed %}
<div class="alert alert-warning">
یک apply در انتظار تأیید است.
<a href="{{ url_for('apply.status', log_id=pending.id) }}">ادامه</a>
</div>
{% endif %}
<div class="row g-3 mb-4">
{% for p in profiles %}
<div class="col-md-6">
<div class="card">
<div class="card-body">
<h5>{{ p.name }}</h5>
<p class="small text-muted">{{ p.description }}</p>
<form method="post" action="{{ url_for('apply.apply', profile_id=p.id) }}">
<div class="mb-2">
<label class="form-label small">پنجره rollback (دقیقه)</label>
<input type="number" name="rollback_minutes" class="form-control form-control-sm" value="15" min="5" max="60">
</div>
<button type="submit" class="btn btn-success" onclick="return confirm('Backup گرفته می‌شود. Docker ممکن است restart شود. ادامه؟')">
اعمال پروفایل
</button>
</form>
</div>
</div>
</div>
{% endfor %}
</div>
<h4>تاریخچه apply</h4>
<div class="table-responsive">
<table class="table table-sm">
<thead><tr><th>پروفایل</th><th>وضعیت</th><th>شروع</th><th></th></tr></thead>
<tbody>
{% for log in recent_logs %}
<tr>
<td>{{ log.profile.name if log.profile else '-' }}</td>
<td><span class="badge bg-secondary">{{ log.status }}</span></td>
<td>{{ log.started_at.strftime('%Y-%m-%d %H:%M') }}</td>
<td><a href="{{ url_for('apply.status', log_id=log.id) }}">جزئیات</a></td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% endblock %}
{% extends "base.html" %}
{% from "macros.html" import guide_box %}
{% block title %}اعمال تنظیمات{% endblock %}
{% block content %}
<h2>اعمال پروفایل</h2>
{{ guide_box(guide, 'profiles') }}
{% if pending and not pending.confirmed %}
<div class="alert alert-warning">
یک تست موقت در انتظار تأیید است.
<a href="{{ url_for('apply.status', log_id=pending.id) }}">ادامه و تأیید / rollback</a>
</div>
{% endif %}
<div class="alert alert-info small">
<strong>توصیه:</strong> همیشه ابتدا «تست موقت» را بزنید.
اگر {{ test_minutes }} دقیقه تأیید نکنید، تنظیمات قبلی خودکار برمی‌گردد.
Docker ممکن است چند ثانیه restart شود.
</div>
<div class="row g-3 mb-4">
{% for p in profiles %}
<div class="col-md-6">
<div class="card">
<div class="card-body">
<h5>{{ p.name }}</h5>
<p class="small text-muted">{{ p.description }}</p>
<ul class="list-unstyled small mb-3">
{% for item in p.items %}
<li>{{ item.category }}: <strong>{{ item.mirror.name if item.mirror else '-' }}</strong></li>
{% endfor %}
</ul>
<div class="d-flex flex-wrap gap-2">
<form method="post" action="{{ url_for('apply.apply_test', profile_id=p.id) }}">
<button type="submit" class="btn btn-warning" onclick="return confirm('تست موقت {{ test_minutes }} دقیقه‌ای اعمال شود؟ در صورت مشکل خودکار rollback می‌شود.')">
تست موقت ({{ test_minutes }} دقیقه)
</button>
</form>