mirror of
https://github.com/tdurieux/anonymous_github.git
synced 2026-07-06 21:57:57 +02:00
refactor: use replicas instead of node forks
This commit is contained in:
+16
-3
@@ -1,10 +1,14 @@
|
|||||||
version: "3"
|
version: "3.8"
|
||||||
|
|
||||||
services:
|
services:
|
||||||
anonymous_github:
|
anonymous_github:
|
||||||
build: .
|
build: .
|
||||||
restart: always
|
restart: always
|
||||||
image: tdurieux/anonymous_github:v2
|
image: tdurieux/anonymous_github:v2
|
||||||
|
deploy:
|
||||||
|
mode: replicated
|
||||||
|
replicas: 4
|
||||||
|
endpoint_mode: vip
|
||||||
env_file:
|
env_file:
|
||||||
- ./.env
|
- ./.env
|
||||||
volumes:
|
volumes:
|
||||||
@@ -12,8 +16,6 @@ services:
|
|||||||
environment:
|
environment:
|
||||||
- REDIS_HOSTNAME=redis
|
- REDIS_HOSTNAME=redis
|
||||||
- DB_HOSTNAME=mongodb
|
- DB_HOSTNAME=mongodb
|
||||||
ports:
|
|
||||||
- $PORT:$PORT
|
|
||||||
healthcheck:
|
healthcheck:
|
||||||
test:
|
test:
|
||||||
- CMD
|
- CMD
|
||||||
@@ -27,6 +29,17 @@ services:
|
|||||||
- redis
|
- redis
|
||||||
- opentelemetry
|
- 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:
|
redis:
|
||||||
image: "redis:alpine"
|
image: "redis:alpine"
|
||||||
restart: always
|
restart: always
|
||||||
|
|||||||
@@ -1,16 +1,7 @@
|
|||||||
const cluster = require('node:cluster');
|
|
||||||
import { config } from "dotenv";
|
import { config } from "dotenv";
|
||||||
config();
|
config();
|
||||||
|
|
||||||
import server from "./src/server";
|
import server from "./src/server";
|
||||||
|
|
||||||
if (cluster.isPrimary) {
|
// start the server
|
||||||
console.log(`Master process ${process.pid} is running`);
|
server();
|
||||||
|
|
||||||
for (let i = 0; i < 8; i++) {
|
|
||||||
cluster.fork();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// start the server
|
|
||||||
server();
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user