mirror of
https://github.com/tcgdex/cards-database.git
synced 2025-04-23 19:32:11 +00:00
Merge branch 'master' into feat/add-openapi-explorer
This commit is contained in:
commit
8f288dfc08
@ -2,9 +2,30 @@ import express, { type Response } from 'express'
|
|||||||
import jsonEndpoints from './V2/endpoints/jsonEndpoints'
|
import jsonEndpoints from './V2/endpoints/jsonEndpoints'
|
||||||
import openapi from './V2/endpoints/openapi'
|
import openapi from './V2/endpoints/openapi'
|
||||||
import graphql from './V2/graphql'
|
import graphql from './V2/graphql'
|
||||||
|
import cluster from 'node:cluster'
|
||||||
|
import { availableParallelism } from "node:os"
|
||||||
import { Errors, sendError } from './libs/Errors'
|
import { Errors, sendError } from './libs/Errors'
|
||||||
import status from './status'
|
import status from './status'
|
||||||
|
|
||||||
|
if (cluster.isPrimary) {
|
||||||
|
console.log(`Primary ${process.pid} is running`);
|
||||||
|
|
||||||
|
const parallelism = availableParallelism()
|
||||||
|
console.log(`creating ${parallelism} workers...`)
|
||||||
|
for (let i = 0; i < parallelism; i++) {
|
||||||
|
cluster.fork();
|
||||||
|
}
|
||||||
|
|
||||||
|
cluster.on('online', (worker) => {
|
||||||
|
console.log('Worker', worker.id, 'online')
|
||||||
|
})
|
||||||
|
|
||||||
|
cluster.on("exit", (worker, code, _signal) => {
|
||||||
|
console.log(`Worker ${worker.id} exited with code ${code}`);
|
||||||
|
})
|
||||||
|
console.log('🚀 Server ready at localhost:3000');
|
||||||
|
} else {
|
||||||
|
|
||||||
// Current API version
|
// Current API version
|
||||||
const VERSION = 2
|
const VERSION = 2
|
||||||
|
|
||||||
@ -96,4 +117,4 @@ server.use((err: Error, _1: unknown, res: Response, _2: unknown) => {
|
|||||||
|
|
||||||
// Start server
|
// Start server
|
||||||
server.listen(3000)
|
server.listen(3000)
|
||||||
console.log('🚀 Server ready at localhost:3000');
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user