update bot

This commit is contained in:
2025-03-08 18:18:23 -07:00
parent ba9bd66efd
commit 7a307f6a6d
4 changed files with 19 additions and 14 deletions

View File

@@ -1,4 +1,4 @@
FROM node:20 as build-stage
FROM node:20 AS build-stage
WORKDIR /app
@@ -8,7 +8,7 @@ RUN npm install
COPY client/ ./
RUN npm run build
FROM python:3.10
FROM python:3.12
RUN apt-get update && apt-get install -y ffmpeg
COPY requirements.txt requirements.txt
RUN pip install -r requirements.txt

View File

@@ -93,20 +93,24 @@ async def stop(ctx: commands.Context):
async def pause(ctx: commands.Context):
pause_song()
def run_websocket():
print("started websocket")
loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop)
start_server = websockets.serve(websocket_handler, "0.0.0.0", 5678)
loop.run_until_complete(start_server)
loop.run_forever()
# def run_websocket():
# print("started websocket")
# loop = asyncio.new_event_loop()
# asyncio.set_event_loop(loop)
# start_server = websockets.serve(websocket_handler, "0.0.0.0", 5678)
# loop.run_until_complete(start_server)
# loop.run_forever()
async def start_websocket_server():
print("Starting WebSocket server...")
async with websockets.serve(websocket_handler, "0.0.0.0", 5678):
await asyncio.Future()
@asynccontextmanager
async def lifespan(app: FastAPI):
Thread(target=run_websocket).start()
Thread(target=lambda: bot.run(os.getenv("DISCORD_SECRET"))).start()
asyncio.create_task(start_websocket_server())
asyncio.create_task(bot.start(os.getenv("DISCORD_SECRET")))
yield
app = FastAPI(lifespan=lifespan)

View File

@@ -6,4 +6,5 @@ websockets
ffmpeg
pydantic
mutagen
fastapi
fastapi
fastapi[standard]

View File

@@ -1,7 +1,7 @@
#!/bin/bash
docker pull node:20
docker pull python:3.10
docker pull python:3.12
docker build -t discord-bot .
# docker run -it --rm discord-bot
@@ -11,7 +11,7 @@ docker rm -f discord-bot || true
docker run -d \
--name discord-bot \
-e DISCORD_SECRET=$DISCORD_SECRET \
--restart always\
--restart always \
-p 0.0.0.0:5677:5677 \
-p 0.0.0.0:5678:5678 \
discord-bot