mirror of
https://github.com/tdurieux/anonymous_github.git
synced 2026-02-12 18:32:44 +00:00
refactor: use replicas instead of node forks
This commit is contained in:
@@ -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
|
||||
|
||||
13
index.ts
13
index.ts
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user