refactor(NetworkConfigManager, mikrotikConfigRoutes): streamline logging and error handling in MikroTik configuration application; remove redundant debug log setup
Publish Fast Tabler Docker image / build-and-push-fast (push) Failing after 2m8s
Publish Fast Tabler Docker image / build-and-push-fast (push) Failing after 2m8s
This commit is contained in:
@@ -13,9 +13,6 @@ const {
|
||||
buildMikrotikConfig,
|
||||
} = require('../utils/mikrotikInterfaceGenerator');
|
||||
const { readS3TextObject } = require('../services/s3Service');
|
||||
if (!process.env.DEBUG?.includes('routeros-api')) {
|
||||
process.env.DEBUG = (process.env.DEBUG || '') + (process.env.DEBUG ? ',' : '') + 'routeros-api:*';
|
||||
}
|
||||
const { RouterOSAPI } = require('node-routeros');
|
||||
const { applyBlock } = require('../services/mikrotikApplyService');
|
||||
|
||||
@@ -351,24 +348,6 @@ async function applyMikrotikConfig(req, res) {
|
||||
});
|
||||
conn.on('error', (e) => log('RouterOS API error', { error: e?.message || String(e), errno: e?.errno }));
|
||||
conn.on('close', () => log('RouterOS API connection closed'));
|
||||
if (streamLogs) {
|
||||
process.env.DEBUG = (process.env.DEBUG || '') + (process.env.DEBUG ? ',' : '') + 'routeros-api:*';
|
||||
global.__mikrotikStreamLog = log;
|
||||
const debugMod = require('debug');
|
||||
const origLog = debugMod.log;
|
||||
if (origLog && !debugMod._mikrotikPatched) {
|
||||
debugMod._mikrotikPatched = true;
|
||||
debugMod.log = function (...args) {
|
||||
try {
|
||||
const msg = args.map((a) => (typeof a === 'object' ? JSON.stringify(a) : String(a))).join(' ');
|
||||
if (msg.includes('routeros-api') && global.__mikrotikStreamLog) {
|
||||
global.__mikrotikStreamLog('node-routeros', { msg });
|
||||
}
|
||||
} catch (_) {}
|
||||
return origLog.apply(this, args);
|
||||
};
|
||||
}
|
||||
}
|
||||
try {
|
||||
log('Connecting to MikroTik', { host: host + ':' + port });
|
||||
await conn.connect();
|
||||
@@ -408,8 +387,6 @@ async function applyMikrotikConfig(req, res) {
|
||||
if (conn) try { conn.close(); } catch (_) {}
|
||||
conn = null;
|
||||
throw err;
|
||||
} finally {
|
||||
delete global.__mikrotikStreamLog;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user