update bot
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
FROM node:20 as build-stage
|
FROM node:20 AS build-stage
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
@@ -8,7 +8,7 @@ RUN npm install
|
|||||||
COPY client/ ./
|
COPY client/ ./
|
||||||
RUN npm run build
|
RUN npm run build
|
||||||
|
|
||||||
FROM python:3.10
|
FROM python:3.12
|
||||||
RUN apt-get update && apt-get install -y ffmpeg
|
RUN apt-get update && apt-get install -y ffmpeg
|
||||||
COPY requirements.txt requirements.txt
|
COPY requirements.txt requirements.txt
|
||||||
RUN pip install -r requirements.txt
|
RUN pip install -r requirements.txt
|
||||||
|
|||||||
@@ -93,20 +93,24 @@ async def stop(ctx: commands.Context):
|
|||||||
async def pause(ctx: commands.Context):
|
async def pause(ctx: commands.Context):
|
||||||
pause_song()
|
pause_song()
|
||||||
|
|
||||||
def run_websocket():
|
# def run_websocket():
|
||||||
print("started websocket")
|
# print("started websocket")
|
||||||
loop = asyncio.new_event_loop()
|
# loop = asyncio.new_event_loop()
|
||||||
asyncio.set_event_loop(loop)
|
# asyncio.set_event_loop(loop)
|
||||||
start_server = websockets.serve(websocket_handler, "0.0.0.0", 5678)
|
# start_server = websockets.serve(websocket_handler, "0.0.0.0", 5678)
|
||||||
loop.run_until_complete(start_server)
|
# loop.run_until_complete(start_server)
|
||||||
loop.run_forever()
|
# 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
|
@asynccontextmanager
|
||||||
async def lifespan(app: FastAPI):
|
async def lifespan(app: FastAPI):
|
||||||
Thread(target=run_websocket).start()
|
asyncio.create_task(start_websocket_server())
|
||||||
Thread(target=lambda: bot.run(os.getenv("DISCORD_SECRET"))).start()
|
asyncio.create_task(bot.start(os.getenv("DISCORD_SECRET")))
|
||||||
yield
|
yield
|
||||||
|
|
||||||
app = FastAPI(lifespan=lifespan)
|
app = FastAPI(lifespan=lifespan)
|
||||||
|
|||||||
@@ -6,4 +6,5 @@ websockets
|
|||||||
ffmpeg
|
ffmpeg
|
||||||
pydantic
|
pydantic
|
||||||
mutagen
|
mutagen
|
||||||
fastapi
|
fastapi
|
||||||
|
fastapi[standard]
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
docker pull node:20
|
docker pull node:20
|
||||||
docker pull python:3.10
|
docker pull python:3.12
|
||||||
docker build -t discord-bot .
|
docker build -t discord-bot .
|
||||||
# docker run -it --rm discord-bot
|
# docker run -it --rm discord-bot
|
||||||
|
|
||||||
@@ -11,7 +11,7 @@ docker rm -f discord-bot || true
|
|||||||
docker run -d \
|
docker run -d \
|
||||||
--name discord-bot \
|
--name discord-bot \
|
||||||
-e DISCORD_SECRET=$DISCORD_SECRET \
|
-e DISCORD_SECRET=$DISCORD_SECRET \
|
||||||
--restart always\
|
--restart always \
|
||||||
-p 0.0.0.0:5677:5677 \
|
-p 0.0.0.0:5677:5677 \
|
||||||
-p 0.0.0.0:5678:5678 \
|
-p 0.0.0.0:5678:5678 \
|
||||||
discord-bot
|
discord-bot
|
||||||
|
|||||||
Reference in New Issue
Block a user