mirror of
https://github.com/Sithranduil/srcds_exporter.git
synced 2025-07-22 14:28:27 +02:00
fix: add some logs
This commit is contained in:
5
index.js
5
index.js
@@ -37,10 +37,15 @@ app.get('/metrics', async (req, res) => {
|
||||
|
||||
try {
|
||||
const client = new SourceRcon.default(config.ip, Number.parseInt(config.port));
|
||||
console.log(`[${config.game} ${config.ip}:${config.port}] connecting`);
|
||||
await client.connect();
|
||||
console.log(`[${config.game} ${config.ip}:${config.port}] connected`);
|
||||
await client.auth(config.rconPassword);
|
||||
console.log(`[${config.game} ${config.ip}:${config.port}] auth`);
|
||||
const response = await module.request(config, client);
|
||||
console.log(`[${config.game} ${config.ip}:${config.port}] request`);
|
||||
await module.send(config, response, res);
|
||||
console.log(`[${config.game} ${config.ip}:${config.port}] send`);
|
||||
} catch (e) {
|
||||
if (e.code === 'EHOSTUNREACH') {
|
||||
console.error(`Unreachable host : ${e.address}:${e.port}`);
|
||||
|
@@ -21,8 +21,13 @@ export default {
|
||||
},
|
||||
async rconCommand(client, command) {
|
||||
try {
|
||||
return client.send(command);
|
||||
console.log(`[${client.host}:${client.port}] rcon command :`, command);
|
||||
const res = await client.send(command);
|
||||
console.log(`[${client.host}:${client.port}] rcon commands result: ${command}`);
|
||||
console.log(res);
|
||||
return res;
|
||||
} catch (err) {
|
||||
|
||||
throw err;
|
||||
}
|
||||
return null;
|
||||
|
Reference in New Issue
Block a user