diff --git a/README.md b/README.md index 2405643e..03de0c11 100644 --- a/README.md +++ b/README.md @@ -16,12 +16,12 @@ Discord for development/support/play: https://discord.gg/5XuDkje * [Windows setup](#windows-setup) +* [Optional plugins](#Plugins) + * [Common problems](#Common-problems) * [Command cheatsheet](#cheatsheet) -* [Optional plugins](#Plugins) - ## Introduction Features: @@ -36,7 +36,7 @@ Features: - Inventory combinator to display item levels in the cluster (and epoch time) -- Reporting of graphs and UPS on master interface +- Reporting of graphs and UPS on master interface (Also has extensive Prometheus reporting) Optional extras (see [Plugins](#Plugins)) @@ -205,6 +205,12 @@ Fancy game client that does the following steps automatically, but is really old 3. Run factorio and connect to slave as a normal MP game. You will find the port number to connect to at http://[masterAddress]:8080 +## Plugins +Here are the known Clusterio plugins in the wild: +1. [Player Manager](https://github.com/Danielv123/playerManager) - Adds player management to the Web UI and shared inventory handling (beta) +2. [DiscordChat](https://github.com/jakedraddy/ClusterioDiscordChat) - Logs in-game chat/joins/leave messages on all instances to a Discord webhook. +3. [TrainTeleports](https://github.com/Godmave/clusterioTrainTeleports) - Allows you to teleport cargotrains between servers. + ## Common problems ### Cannot find module: `/../../config` @@ -227,6 +233,22 @@ if that does not suffice do If it still doesn't work, come over to our support discord linked at the top of this readme. +### Portforwarding doesn't work on the master server when running under WSL + +If you follow the ubuntu guide on WSL (Windows Subsystem for Linux, Bash on Ubuntu on Windows specifically), you will find that the website works on localhost and on your local ip, but not on the global ip. This is also true when you correctly port-forwarded the correct ports. Even when routing this server through nginx in WSL, the issue persists. Then, on a hunch, I tried to run nginx from windows itself and found that this DID work. It came to me that the only usage difference between the 2 versions of nginx is that I got a Windows Firewall popup. + +TLDR: the tested fix is: + +- open your windows firewall and go to advanced settings + +- click on inbound rules and click on new rule... + +- select port and click next > + +- select TCP and select specific local ports and type in the ports that you want to open (comma separated) and click next > 3 times + +- give the rule a name (like 'web server' or something), give it a description (optionally) and click finish + ### Other fixes for other potential problems: Sometimes the install fails. Try `node ./lib/npmPostinstall.js` to complete it. @@ -259,9 +281,3 @@ npm install ``` node client.js manage shared mods add clusterio ``` - -## Plugins -Here are the known Clusterio plugins in the wild: -1. [Player Manager](https://github.com/Danielv123/playerManager) - Adds player management to the Web UI and shared inventory handling (beta) -2. [DiscordChat](https://github.com/jakedraddy/ClusterioDiscordChat) - Logs in-game chat/joins/leave messages on all instances to a Discord webhook. -3. [TrainTeleports](https://github.com/Godmave/clusterioTrainTeleports) - Allows you to teleport cargotrains between servers. diff --git a/master.js b/master.js index 3c8bb14b..0e72e40c 100644 --- a/master.js +++ b/master.js @@ -148,11 +148,6 @@ const prometheusWsUsageCounter = new Prometheus.Counter({ help: 'Websocket traffic', labelNames: ["connectionType", "instanceID"], }); -const prometheusProductionGauge = new Prometheus.Gauge({ - name: prometheusPrefix+'production_gauge', - help: 'Items produced by instance', - labelNames: ["instanceID", "itemName"], -}); const prometheusExportGauge = new Prometheus.Gauge({ name: prometheusPrefix+'export_gauge', help: 'Items exported by instance', @@ -202,7 +197,7 @@ app.get('/metrics', (req, res) => { res.set('Content-Type', Prometheus.register.contentType); /// gather some static metrics - reisterMoreMetrics(); + registerMoreMetrics(); res.end(Prometheus.register.metrics()); }); @@ -642,44 +637,6 @@ app.get("/api/inventoryAsObject", function(req, res) { res.send(JSON.stringify(db.items)); }); -// post flowstats here for production graphs -// {timestamp: Date, instanceID: string, data: {"item":number}} -/** --- TODO: Replace this with a simpler Prometheus exporter. Requires changes to the mod as well. -POST endpoint to log production graph statistics. Should contain a timestamp -gathered from Date.now(), a instanceID (also reffered to as "unique") and of -course the timeSeries data. - -@memberof clusterioMaster -@instance -@alias api/logStats -@param {object} JSON {timestamp: Date.now(), instanceID: "string", data: {"item": number}} -@returns {string} failure -*/ -app.post("/api/logStats", authenticate.middleware, function(req,res) { - endpointHitCounter.labels(req.route.path).inc(); - if(typeof req.body == "object" && req.body.instanceID && req.body.timestamp && req.body.data) { - if(Number(req.body.timestamp) != NaN){ - req.body.timestamp = Number(req.body.timestamp); - db.flows.insert({ - instanceID: req.body.instanceID, - timestamp: req.body.timestamp, - data: req.body.data, - }); - try{ - Object.keys(req.body.data).forEach(itemName => { - prometheusProductionGauge.labels(req.body.instanceID, itemName).inc(Number(req.body.data[itemName]) || 0); - }); - }catch(e){console.log(e)}; - console.log("inserted: " + req.body.instanceID + " | " + req.body.timestamp); - } else { - console.log("error invalid timestamp " + req.body.timestamp); - res.send("failure"); - } - } else { - res.send("failure"); - } -}); - /** POST endpoint for running commands on slaves. Requires x-access-token header to be set. Find you api token in secret-api-token.txt on the master (after running it once) @@ -974,6 +931,7 @@ async function getPlugins(){ path: pluginConfig.pluginPath, socketio: io, express: app, + Prometheus, }), pluginConfig, });