Files
lottery_ycms/lottery/bot/tasks.py

21 lines
540 B
Python

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"