Allow sound player to start even if some nodes are down, docker maintenance

This commit is contained in:
TheEssem 2020-12-11 16:46:05 -06:00
parent 0566dca06d
commit a1c24ea30d
4 changed files with 20 additions and 12 deletions

View file

@ -42,11 +42,15 @@ RUN update-ms-fonts && fc-cache -f
RUN adduser esmBot -s /bin/sh -D RUN adduser esmBot -s /bin/sh -D
WORKDIR /home/esmBot/.internal WORKDIR /home/esmBot/.internal
COPY ./assets/caption.otf /home/esmBot/.font/caption.otf
COPY ./assets/caption2.ttf /home/esmBot/.font/caption2.ttf
COPY ./assets/hbc.ttf /home/esmBot/.font/hbc.ttf
RUN fc-cache -f
COPY ./package.json package.json COPY ./package.json package.json
COPY ./package-lock.json package-lock.json COPY ./package-lock.json package-lock.json
RUN npm install RUN npm install
COPY . . COPY . .
RUN npm run build
USER esmBot USER esmBot
EXPOSE 3000 EXPOSE 3000

View file

@ -41,11 +41,16 @@ RUN update-ms-fonts && fc-cache -f
RUN adduser esmBot -s /bin/sh -D RUN adduser esmBot -s /bin/sh -D
WORKDIR /home/esmBot/.internal WORKDIR /home/esmBot/.internal
COPY ./assets/caption.otf /home/esmBot/.font/caption.otf
COPY ./assets/caption2.ttf /home/esmBot/.font/caption2.ttf
COPY ./assets/hbc.ttf /home/esmBot/.font/hbc.ttf
RUN fc-cache -f
COPY ./package.json package.json COPY ./package.json package.json
COPY ./package-lock.json package-lock.json COPY ./package-lock.json package-lock.json
RUN npm install RUN npm install
COPY . . COPY . .
RUN npm run build
USER esmBot USER esmBot
ENTRYPOINT ["node", "app.js"] ENTRYPOINT ["node", "app.js"]

View file

@ -9,7 +9,7 @@ services:
restart: unless-stopped restart: unless-stopped
volumes: volumes:
- ./logs:/home/esmBot/.internal/logs - ./logs:/home/esmBot/.internal/logs
- bot-output:/home/esmBot/output - bot-help:/home/esmBot/help
- bot-temp:/home/esmBot/temp - bot-temp:/home/esmBot/temp
env_file: env_file:
- .env - .env
@ -88,7 +88,7 @@ services:
ipv4_address: 172.20.0.7 ipv4_address: 172.20.0.7
volumes: volumes:
bot-output: bot-help:
bot-temp: bot-temp:
mongo-data: mongo-data:
@ -98,4 +98,3 @@ networks:
ipam: ipam:
config: config:
- subnet: 172.20.0.0/24 - subnet: 172.20.0.0/24
gateway: 172.20.0.1

View file

@ -6,7 +6,7 @@ const moment = require("moment");
require("moment-duration-format"); require("moment-duration-format");
const { Manager } = require("@lavacord/eris"); const { Manager } = require("@lavacord/eris");
const nodes = require("../servers.json").lava; let nodes = require("../servers.json").lava;
exports.players = new Map(); exports.players = new Map();
@ -20,17 +20,17 @@ exports.status = false;
exports.connected = false; exports.connected = false;
exports.checkStatus = async () => { exports.checkStatus = async () => {
const statuses = []; const newNodes = [];
for (const node of nodes) { for (const node of nodes) {
try { try {
const response = await fetch(`http://${node.host}:${node.port}/version`, { headers: { Authorization: node.password } }).then(res => res.text()); const response = await fetch(`http://${node.host}:${node.port}/version`, { headers: { Authorization: node.password } }).then(res => res.text());
if (response) statuses.push(false); if (response) newNodes.push(node);
} catch { } catch {
statuses.push(true); logger.log(`Failed to get status of Lavalink node ${node.host}.`);
} }
} }
const result = statuses.filter(Boolean); nodes = newNodes;
this.status = result.length > 0 ? true : false; this.status = newNodes.length === 0 ? true : false;
return this.status; return this.status;
}; };