]> git.sesse.net Git - remoteglot/blobdiff - www/serve-analysis.js
Make serve-analysis.js capable of listening on a different port.
[remoteglot] / www / serve-analysis.js
index a5713e2d3059ac96df29d4baa2bfd2e4a57d598c..40d4f194f0e1b45f557168e0fdeb9185b55039f8 100644 (file)
@@ -15,6 +15,9 @@ var JSON_FILENAME = '/srv/analysis.sesse.net/www/analysis.json';
 var HISTORY_TO_KEEP = 5;
 var MINIMUM_VERSION = null;
 
 var HISTORY_TO_KEEP = 5;
 var MINIMUM_VERSION = null;
 
+// TCP port to listen on; can be overridden with flags.
+var port = 5000;
+
 // If set to 1, we are already processing a JSON update and should not
 // start a new one. If set to 2, we are _also_ having one in the queue.
 var json_lock = 0;
 // If set to 1, we are already processing a JSON update and should not
 // start a new one. If set to 2, we are _also_ having one in the queue.
 var json_lock = 0;
@@ -183,7 +186,7 @@ var send_json = function(response, ims, accept_gzip, num_viewers) {
                'Content-Type': 'text/json',
                'X-RGLM': this_json.last_modified,
                'X-RGNV': num_viewers,
                'Content-Type': 'text/json',
                'X-RGLM': this_json.last_modified,
                'X-RGNV': num_viewers,
-               'Access-Control-Expose-Headers': 'X-RGLM, X-RGNV',
+               'Access-Control-Expose-Headers': 'X-RGLM, X-RGNV, X-RGMV',
                'Vary': 'Accept-Encoding',
        };
 
                'Vary': 'Accept-Encoding',
        };
 
@@ -297,4 +300,8 @@ server.on('connection', function(socket) {
                }
        });
 });
                }
        });
 });
-server.listen(5000);
+
+if (process.argv.length >= 3) {
+       port = parseInt(process.argv[2]);
+}
+server.listen(port);