aboutsummaryrefslogtreecommitdiff
path: root/server.js
diff options
context:
space:
mode:
Diffstat (limited to 'server.js')
-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);