Merge pull request #18 from H4CK3R-01/monitoring_functions

Added monitoring functions
This commit is contained in:
H4CK3R-01 2021-06-10 19:53:22 +02:00 committed by GitHub
commit 3773fb427b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 1603 additions and 467 deletions

View File

@ -1,9 +1,10 @@
let express = require('express');
let fs = require('fs');
let app = express();
let server = require('http').createServer(app);
let {Server} = require("socket.io");
let io = new Server(server);
const express = require('express');
const fs = require('fs');
const {instrument} = require("@socket.io/admin-ui");
const app = express();
const server = require('http').createServer(app);
const {Server} = require("socket.io");
const io = new Server(server);
let cards = JSON.parse(fs.readFileSync(__dirname + '/../data/fragen_10_06_21_final_new_format.json'));
let port = 5000;
@ -11,10 +12,22 @@ server.listen(port, function () {
generate_log_message("MAIN", "Server", 'RUNNING', "PORT " + port);
});
// Monitor websockets
instrument(io, {
auth: {
type: "basic",
username: process.env.WEBSOCKET_MONITOR_USERNAME,
password: process.env.WEBSOCKET_MONITOR_PASSWORD
},
serverId: `${require("os").hostname()}#${process.pid}`
});
// Serve static files (html, css, js)
app.use(express.static(__dirname + '/../public'));
// Websockets
io.on('connection', socket => {
let addedUser = false;
@ -114,5 +127,5 @@ function shuffleAnswers(card) {
function pad(width, string, padding) {
if (string === undefined || string === null) return pad(width, " ", " ");
return (width <= string.length) ? string : pad(width, string + padding, padding)
return (width <= string.length) ? string : pad(width, string + padding, padding);
}

1918
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -2,6 +2,7 @@
"name": "projektmanagement-game",
"version": "1.0.0",
"dependencies": {
"@socket.io/admin-ui": "^0.1.2",
"express": "^4.17.1",
"socket.io": "^4.1.2"
}