From b585663f07f62094fc2a8a02dcee41e82fa44077 Mon Sep 17 00:00:00 2001 From: Tom Smeding Date: Sat, 17 Feb 2024 20:54:55 +0100 Subject: Configurable port --- server.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/server.js b/server.js index faf7954..217d152 100755 --- a/server.js +++ b/server.js @@ -3,7 +3,17 @@ const http = require("http"); const express = require("express"); const socketio = require("socket.io") -const PORT = 8080; +const PORT = (() => { + if (process.argv.length == 3) { + return +process.argv[2]; + } else if (process.argv.length == 2) { + return 8080; + } else { + console.log("Usage: server.js [port]"); + process.exit(1); + } +})(); + const app = express(); const server = http.Server(app); -- cgit v1.2.3-70-g09d2