feat: add systemd restart
Some checks failed
black-action / runner / black formatter (push) Failing after 39s
Some checks failed
black-action / runner / black formatter (push) Failing after 39s
This commit is contained in:
parent
b6434be432
commit
502de803b8
@ -20,14 +20,18 @@ PING_URL = os.environ.get(
|
|||||||
"https://healthchecks.projectsegfau.lt/ping/2f7f2cd3-2a8d-4fff-b5ca-f4d17d47f75b",
|
"https://healthchecks.projectsegfau.lt/ping/2f7f2cd3-2a8d-4fff-b5ca-f4d17d47f75b",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
SYSTEMD_SERVICE_NAME = os.environ.get("SYSTEMD_SERVICE_NAME", "matrixai")
|
||||||
|
|
||||||
import io
|
import io
|
||||||
|
|
||||||
import aiohttp
|
import aiohttp
|
||||||
|
import asyncio
|
||||||
|
import os
|
||||||
from langdetect import detect
|
from langdetect import detect
|
||||||
|
|
||||||
from enum import Enum
|
from enum import Enum
|
||||||
import uuid
|
import uuid
|
||||||
|
import subprocess
|
||||||
|
|
||||||
class Style(Enum):
|
class Style(Enum):
|
||||||
"""
|
"""
|
||||||
@ -856,8 +860,12 @@ Help Message:
|
|||||||
):
|
):
|
||||||
await bot.api.send_text_message(room.room_id, bot_help_message)
|
await bot.api.send_text_message(room.room_id, bot_help_message)
|
||||||
|
|
||||||
bot.run()
|
try:
|
||||||
|
bot.run()
|
||||||
|
except Exception as e:
|
||||||
|
subprocess.run(["systemctl", "restart", "--user", SYSTEMD_SERVICE_NAME])
|
||||||
|
print("Restarting bot due to {e}")
|
||||||
|
return 1
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
sys.exit(run())
|
sys.exit(run())
|
||||||
|
Loading…
Reference in New Issue
Block a user