Allow sound player to start even if some nodes are down, docker maintenance
This commit is contained in:
parent
0566dca06d
commit
a1c24ea30d
4 changed files with 20 additions and 12 deletions
|
@ -42,11 +42,15 @@ RUN update-ms-fonts && fc-cache -f
|
|||
RUN adduser esmBot -s /bin/sh -D
|
||||
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-lock.json package-lock.json
|
||||
RUN npm install
|
||||
COPY . .
|
||||
RUN npm run build
|
||||
USER esmBot
|
||||
|
||||
EXPOSE 3000
|
||||
|
|
|
@ -41,11 +41,16 @@ RUN update-ms-fonts && fc-cache -f
|
|||
|
||||
RUN adduser esmBot -s /bin/sh -D
|
||||
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-lock.json package-lock.json
|
||||
RUN npm install
|
||||
COPY . .
|
||||
RUN npm run build
|
||||
USER esmBot
|
||||
|
||||
ENTRYPOINT ["node", "app.js"]
|
|
@ -9,7 +9,7 @@ services:
|
|||
restart: unless-stopped
|
||||
volumes:
|
||||
- ./logs:/home/esmBot/.internal/logs
|
||||
- bot-output:/home/esmBot/output
|
||||
- bot-help:/home/esmBot/help
|
||||
- bot-temp:/home/esmBot/temp
|
||||
env_file:
|
||||
- .env
|
||||
|
@ -88,7 +88,7 @@ services:
|
|||
ipv4_address: 172.20.0.7
|
||||
|
||||
volumes:
|
||||
bot-output:
|
||||
bot-help:
|
||||
bot-temp:
|
||||
mongo-data:
|
||||
|
||||
|
@ -97,5 +97,4 @@ networks:
|
|||
driver: bridge
|
||||
ipam:
|
||||
config:
|
||||
- subnet: 172.20.0.0/24
|
||||
gateway: 172.20.0.1
|
||||
- subnet: 172.20.0.0/24
|
|
@ -6,7 +6,7 @@ const moment = require("moment");
|
|||
require("moment-duration-format");
|
||||
const { Manager } = require("@lavacord/eris");
|
||||
|
||||
const nodes = require("../servers.json").lava;
|
||||
let nodes = require("../servers.json").lava;
|
||||
|
||||
exports.players = new Map();
|
||||
|
||||
|
@ -20,17 +20,17 @@ exports.status = false;
|
|||
exports.connected = false;
|
||||
|
||||
exports.checkStatus = async () => {
|
||||
const statuses = [];
|
||||
const newNodes = [];
|
||||
for (const node of nodes) {
|
||||
try {
|
||||
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 {
|
||||
statuses.push(true);
|
||||
logger.log(`Failed to get status of Lavalink node ${node.host}.`);
|
||||
}
|
||||
}
|
||||
const result = statuses.filter(Boolean);
|
||||
this.status = result.length > 0 ? true : false;
|
||||
nodes = newNodes;
|
||||
this.status = newNodes.length === 0 ? true : false;
|
||||
return this.status;
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue