env.gameEngineManualStart

This commit is contained in:
2024-03-14 14:50:08 +00:00
parent 533400b1b9
commit 3e4129c3f1
3 changed files with 21 additions and 8 deletions
+2
View File
@@ -27,6 +27,8 @@ declare namespace NodeJS {
API_ROOT_PATH?: string;
VITE_API_ROOT_PATH?: string;
GAME_ENGINE_MANUAL_START?: string; //숫자->Boolean
PRESHARED_SECURE_TOKEN_SECRET?: string; //길게
}
}
+11 -2
View File
@@ -7,6 +7,7 @@ import { buildAPISystem } from '@strpc/express/generator';
import { sammoAPI } from './api/index.js';
import { unwrap } from '@sammo/util';;
import { serverConfig } from './serverConfig.js';
import { getGameEngineController } from './GameEngineController.js';
connectDB.then(async (db) => {
// create express app
@@ -22,9 +23,17 @@ connectDB.then(async (db) => {
app.use('/api', buildAPISystem(sammoAPI));
// start express server
app.listen(serverConfig.port)
app.listen(serverConfig.port, "0.0.0.0", async ()=>{
console.log(`Express server has started on port ${serverConfig.port}`);
if(serverConfig.gameEngineManualStart){
console.log("Game Engine is not started automatically.");
return;
}
await getGameEngineController().start();
})
console.log(`Express server has started on port ${serverConfig.port}`)
}).catch(error => console.log(error));
+8 -6
View File
@@ -1,9 +1,11 @@
import 'dotenv/config';
import { unwrap } from '@sammo/util';
import { must } from '@sammo/util';
export const serverConfig = {
sessionSecret: unwrap(process.env.SESSION_SECRET),
port: Number(unwrap(process.env.SERVER_PORT)),
gatewayHost: unwrap(process.env.GATEWAY_HOST),
gatewayPort: Number(unwrap(process.env.GATEWAY_PORT)),
};
sessionSecret: must(process.env.SESSION_SECRET),
port: Number(must(process.env.SERVER_PORT)),
gatewayHost: must(process.env.GATEWAY_HOST),
gatewayPort: Number(must(process.env.GATEWAY_PORT)),
gameEngineManualStart: Boolean(Number(process.env.GAME_ENGINE_MANUAL_START??'0'))
} as const;