env.gameEngineManualStart
This commit is contained in:
Vendored
+2
@@ -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; //길게
|
||||
}
|
||||
}
|
||||
@@ -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));
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user