diff options
author | Tom Smeding <t.j.smeding@uu.nl> | 2024-02-17 20:54:55 +0100 |
---|---|---|
committer | Tom Smeding <t.j.smeding@uu.nl> | 2024-02-17 20:54:55 +0100 |
commit | b585663f07f62094fc2a8a02dcee41e82fa44077 (patch) | |
tree | ac4c58e1aff8aab64b1e2f1d4ae0bbbcc6284bff | |
parent | 412961277249688fc8a1cc25a5358987bbe49363 (diff) |
Configurable port
-rwxr-xr-x | server.js | 12 |
1 files changed, 11 insertions, 1 deletions
@@ -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); |