Bot container restart from admin-panel

This commit is contained in:
2025-07-21 17:16:07 +09:00
parent 20f67ed96c
commit 421bebb770
267 changed files with 2307 additions and 300 deletions

21
lottery/bot/tasks.py Normal file
View File

@@ -0,0 +1,21 @@
from celery import shared_task
import subprocess
@shared_task
def restart_bot_container(container_name="bot"):
try:
result = subprocess.run(
["docker", "restart", container_name],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
text=True,
check=True
)
return f"Success: {result.stdout.strip()}"
except subprocess.CalledProcessError as e:
return f"Error restarting container: {e.stderr.strip()}"
@shared_task
def ping():
return "pong"