refactor: use replicas instead of node forks

This commit is contained in:
tdurieux
2024-04-01 06:43:51 +01:00
parent d3924698f6
commit d2aa5d6361
2 changed files with 18 additions and 14 deletions

View File

@@ -1,10 +1,14 @@
version: "3"
version: "3.8"
services:
anonymous_github:
build: .
restart: always
image: tdurieux/anonymous_github:v2
deploy:
mode: replicated
replicas: 4
endpoint_mode: vip
env_file:
- ./.env
volumes:
@@ -12,8 +16,6 @@ services:
environment:
- REDIS_HOSTNAME=redis
- DB_HOSTNAME=mongodb
ports:
- $PORT:$PORT
healthcheck:
test:
- CMD
@@ -27,6 +29,17 @@ services:
- redis
- opentelemetry
nginx:
image: nginx:stable-alpine
env_file:
- ./.env
volumes:
- ./nginx.conf:/etc/nginx/conf.d/default.conf:ro
depends_on:
- anonymous_github
ports:
- "$EXPOSED_PORT:4000"
redis:
image: "redis:alpine"
restart: always

View File

@@ -1,16 +1,7 @@
const cluster = require('node:cluster');
import { config } from "dotenv";
config();
import server from "./src/server";
if (cluster.isPrimary) {
console.log(`Master process ${process.pid} is running`);
for (let i = 0; i < 8; i++) {
cluster.fork();
}
} else {
// start the server
server();
}
// start the server
server();