1
0
Fork 0
mirror of https://github.com/uhIgnacio/EmoteManager.git synced 2024-08-15 02:23:13 +00:00

move systemd to bot bin

This commit is contained in:
io mintz 2020-07-01 06:44:33 +00:00
parent 68227a2b44
commit 1c08a9bc67
5 changed files with 2 additions and 362 deletions

View file

@ -1,33 +0,0 @@
import asyncio
import os
import socket
from discord.ext import commands
from utils.socket import open_datagram_endpoint
class SystemdNotifier(commands.Cog):
def __init__(self):
self.os_sock = socket.socket(family=socket.AF_UNIX, type=socket.SOCK_DGRAM)
self.connect_task = asyncio.create_task(self.connect())
self.addr = os.environ['NOTIFY_SOCKET']
def send(self, msg):
self.sock.send(msg, self.addr)
async def connect(self):
self.sock = await open_datagram_endpoint(sock=self.os_sock)
def cog_unload(self):
self.connect_task.cancel()
@commands.Cog.listener()
async def on_shard_ready(self, shard_id):
self.send(b'STATUS=Ready on shard %d' % shard_id)
@commands.Cog.listener()
async def on_ready(self):
self.send(b'READY=1')
def setup(bot):
bot.add_cog(SystemdNotifier())