Danil_Valov Posted January 7, 2017 Share Posted January 7, 2017 Create file `monitoring.js` to directory `packages/keker` with the following code: // Require nodejs module `http` const http = require('http'); // Create web server const server = http.createServer(function(request, response) { // Show monitoring for any request response.writeHead(200, {"Content-Type": "text/html"}); response.write(`<br>Players: ${mp.players.length}/${mp.players.size}`); response.write(`<br>Uptime: ${process.uptime()}`); response.end(); }); // Turn on the web server on the port 8080 // (you can change it to any port) server.listen(8080); // Show message in terminal about successful starting of Monitoring Server console.log('\nMonitoring Server is listening'); Append to file `packages/keker/index.js` the following code: require('./monitoring'); Now when you open url http://your_ip:8080 you see the following data: Цитата Players: 1/100 Uptime: 637.516 Also you can change the port of web server in `monitoring.js`. And you can change the data format to JSON if you need. 5 Link to comment Share on other sites More sharing options...
Urukhay Posted January 11, 2017 Share Posted January 11, 2017 (edited) Why is "netstat -nlp" not listening port 8080 after running ragemp-server with this monitoring? But service "node monitoring.js" activates the port 8080. Maybe this because i have installed node_modules in the root server directory (where conf.json)? Because i tested require with another file (mysqlSaver.js that requires npm Mysql) from index.js, but mysql-function was not called from index.js. Like the: "use strict"; global.dimensions = {}; const events = require('./events'); var f = require("./mysqlSaver.js"); // my file that requires mysql from npm (provides module.exports.savePlayer as function) f.savePlayer("Test"); // Mysql-saving not happend Edited January 11, 2017 by Urukhay Link to comment Share on other sites More sharing options...
Danil_Valov Posted January 14, 2017 Author Share Posted January 14, 2017 В 11.01.2017 в 10:22, Urukhay сказал: Why is "netstat -nlp" not listening port 8080 after running ragemp-server with this monitoring? But service "node monitoring.js" activates the port 8080. If you use the Docker then you need to open this port (8080) there. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now