chore: Allow websockets and collaboration service to run in the same process (#2674)

This commit is contained in:
Tom Moor
2021-10-19 21:18:20 -07:00
committed by GitHub
parent 3610a7f4a2
commit d443abfc57
11 changed files with 67 additions and 76 deletions

View File

@ -33,9 +33,17 @@ const serviceNames = uniq(
// The number of processes to run, defaults to the number of CPU's available
// for the web service, and 1 for collaboration during the beta period.
const processCount = serviceNames.includes("collaboration")
? 1
: env.WEB_CONCURRENCY || undefined;
let processCount = env.WEB_CONCURRENCY || undefined;
if (serviceNames.includes("collaboration")) {
if (env.WEB_CONCURRENCY !== 1) {
Logger.info(
"lifecycle",
"Note: Restricting process count to 1 due to use of collaborative service"
);
}
processCount = 1;
}
// This function will only be called once in the original process
function master() {
@ -72,15 +80,6 @@ async function start(id: string, disconnect: () => void) {
router.get("/_health", (ctx) => (ctx.body = "OK"));
app.use(router.routes());
if (
serviceNames.includes("websockets") &&
serviceNames.includes("collaboration")
) {
throw new Error(
"Cannot run websockets and collaboration services in the same process"
);
}
// loop through requested services at startup
for (const name of serviceNames) {
if (!Object.keys(services).includes(name)) {