mirror of
https://github.com/Sithranduil/srcds_exporter.git
synced 2025-07-22 23:28:26 +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 {
|
try {
|
||||||
const client = new SourceRcon.default(config.ip, Number.parseInt(config.port));
|
const client = new SourceRcon.default(config.ip, Number.parseInt(config.port));
|
||||||
|
console.log(`[${config.game} ${config.ip}:${config.port}] connecting`);
|
||||||
await client.connect();
|
await client.connect();
|
||||||
|
console.log(`[${config.game} ${config.ip}:${config.port}] connected`);
|
||||||
await client.auth(config.rconPassword);
|
await client.auth(config.rconPassword);
|
||||||
|
console.log(`[${config.game} ${config.ip}:${config.port}] auth`);
|
||||||
const response = await module.request(config, client);
|
const response = await module.request(config, client);
|
||||||
|
console.log(`[${config.game} ${config.ip}:${config.port}] request`);
|
||||||
await module.send(config, response, res);
|
await module.send(config, response, res);
|
||||||
|
console.log(`[${config.game} ${config.ip}:${config.port}] send`);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (e.code === 'EHOSTUNREACH') {
|
if (e.code === 'EHOSTUNREACH') {
|
||||||
console.error(`Unreachable host : ${e.address}:${e.port}`);
|
console.error(`Unreachable host : ${e.address}:${e.port}`);
|
||||||
|
@@ -21,8 +21,13 @@ export default {
|
|||||||
},
|
},
|
||||||
async rconCommand(client, command) {
|
async rconCommand(client, command) {
|
||||||
try {
|
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) {
|
} catch (err) {
|
||||||
|
|
||||||
throw err;
|
throw err;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
Reference in New Issue
Block a user