Files
fluxer/docker/docker-compose.yml
T
NoLogicAlan 90a53f047f Optimize MySQL connection pools & add Docker healthcheck with graceful queue flush (#21, #12)
- Unify MySQL pools in src/db/PoolManager.mjs shared across Settings, TrackOptions, LastFm, Dashboard, and PlayerStateStore
- Support global config.mysql.connectionLimit (default 15), preventing connection starvation
- Add gracefulShutdown() in Bot.mjs to flush active player queues and playback positions to MySQL on SIGTERM/SIGINT
- Update shard.mjs to forward SIGTERM and await shard worker queue flushes before exit
- Add event-loop responsiveness healthcheck in docker-compose.yml and Dockerfile via heartbeat probe
- Document connectionLimit and queue persistence in README and config templates
2026-10-22 01:37:42 +03:00

93 lines
2.5 KiB
YAML

services:
bot:
build:
context: ..
dockerfile: docker/Dockerfile
container_name: remix-bot
restart: unless-stopped
command: node shard.mjs
depends_on:
mysql:
condition: service_healthy
redis:
condition: service_healthy
nodelink:
condition: service_healthy
volumes:
- ./config.json:/app/config.json
- ../storage:/app/storage
environment:
- TZ=${TZ:-UTC}
ports:
- "${WEB_PORT:-8080}:80"
healthcheck:
test: ["CMD", "node", "-e", "const fs = require('fs'); try { const diff = Date.now() - fs.statSync('/tmp/.remix-health').mtimeMs; process.exit(diff < 30000 ? 0 : 1); } catch { process.exit(1); }"]
interval: 15s
timeout: 5s
retries: 3
start_period: 45s
networks:
- remix-net
mysql:
image: mysql:8.4
container_name: remix-mysql
restart: unless-stopped
environment:
MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD:-remix_root_pw}
MYSQL_DATABASE: ${MYSQL_DATABASE:-remix}
MYSQL_USER: ${MYSQL_USER:-remix}
MYSQL_PASSWORD: ${MYSQL_PASSWORD:-remix_pw}
volumes:
- mysql_data:/var/lib/mysql
healthcheck:
test: ["CMD", "mysqladmin", "ping", "-h", "localhost", "-u", "root", "-p${MYSQL_ROOT_PASSWORD:-remix_root_pw}"]
interval: 10s
timeout: 5s
retries: 10
start_period: 30s
networks:
- remix-net
redis:
image: redis:7-alpine
container_name: remix-redis
restart: unless-stopped
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 10s
timeout: 3s
retries: 5
networks:
- remix-net
nodelink:
image: node:22-bookworm-slim
container_name: remix-nodelink
restart: unless-stopped
working_dir: /nodelink
command: sh -c "if [ ! -f package.json ]; then npm init -y && npm install @performanc/nodelink; fi; node node_modules/@performanc/nodelink/index.js || node index.js"
environment:
- TZ=${TZ:-UTC}
volumes:
- nodelink_data:/nodelink
- ./nodelink.config.json:/nodelink/config.json:ro
ports:
- "${NODELINK_PORT:-3000}:3000"
healthcheck:
test: ["CMD", "node", "-e", "require('net').connect(3000,'127.0.0.1').on('connect',function(){process.exit(0)}).on('error',function(){process.exit(1)})"]
interval: 5s
timeout: 3s
retries: 30
start_period: 60s
networks:
- remix-net
volumes:
mysql_data:
nodelink_data:
networks:
remix-net:
driver: bridge