aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Smeding <t.j.smeding@uu.nl>2024-02-17 20:54:55 +0100
committerTom Smeding <t.j.smeding@uu.nl>2024-02-17 20:54:55 +0100
commitb585663f07f62094fc2a8a02dcee41e82fa44077 (patch)
treeac4c58e1aff8aab64b1e2f1d4ae0bbbcc6284bff
parent412961277249688fc8a1cc25a5358987bbe49363 (diff)
Configurable port
-rwxr-xr-xserver.js12
1 files changed, 11 insertions, 1 deletions
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);