diff --git a/source/server/index.ts b/source/server/index.ts index 0462bab5..41b817d8 100644 --- a/source/server/index.ts +++ b/source/server/index.ts @@ -25,20 +25,11 @@ import("source-map-support").then((s)=>{ }, (e)=>console.log("Source maps not supported")); - -//////////////////////////////////////////////////////////////////////////////// -// CONFIGURATION - -const port: number = parseInt(process.env["VOYAGER_SERVER_PORT"]|| "8000") ; - - (async ()=>{ let root = path.resolve(config.root_dir); - console.info("Serve directory : "+root); + console.info("Serve directory : "+root+" on "+config.port); const app = await createServer(config); - - app.listen(port, () => { - console.info(`Server ready and listening on port ${port}\n`); - app.locals.port = port; + app.listen(config.port, () => { + console.info(`Server ready and listening on port ${config.port}\n`); }); })(); diff --git a/source/server/utils/config.ts b/source/server/utils/config.ts index 40e2aad5..c6f07724 100644 --- a/source/server/utils/config.ts +++ b/source/server/utils/config.ts @@ -6,7 +6,7 @@ const values = { node_env:["development", toString], public: [true, toBool], brand: ["eCorpus", toString], - port: [8000, toUInt ], + port: [8000, toListenTarget ], force_migration: [false, toBool], clean_database: [true, toBool], root_dir: [ process.cwd(), toPath], @@ -52,6 +52,14 @@ function toUInt(s:string):number{ return n; } +function toListenTarget(s:string):number|string{ + try{ + return toUInt(s); + }catch(e){ + return s; + } +} + function toBool(s:string):boolean{ return !(!s || s.toLowerCase() === "false" || s == "0"); } diff --git a/source/server/utils/locals.ts b/source/server/utils/locals.ts index 484c35ec..6f785bd4 100644 --- a/source/server/utils/locals.ts +++ b/source/server/utils/locals.ts @@ -9,7 +9,6 @@ import Templates from "./templates.js"; import { Config } from "./config.js"; export interface AppLocals extends Record{ - port :number; fileDir :string; userManager :UserManager; vfs :Vfs;