Skip to content

Commit

Permalink
support listening on unix sockets
Browse files Browse the repository at this point in the history
  • Loading branch information
sdumetz committed Oct 17, 2024
1 parent 174fc8b commit d18b883
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 14 deletions.
15 changes: 3 additions & 12 deletions source/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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`);
});
})();
10 changes: 9 additions & 1 deletion source/server/utils/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand Down Expand Up @@ -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");
}
Expand Down
1 change: 0 additions & 1 deletion source/server/utils/locals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import Templates from "./templates.js";
import { Config } from "./config.js";

export interface AppLocals extends Record<string, any>{
port :number;
fileDir :string;
userManager :UserManager;
vfs :Vfs;
Expand Down

0 comments on commit d18b883

Please sign in to comment.