♻️ refactor(diagnosticTab): remove unused debug
This commit is contained in:
@@ -326,23 +326,13 @@ async function checkBypass() {
|
|||||||
async function getPodkopErrors() {
|
async function getPodkopErrors() {
|
||||||
return new Promise(resolve => {
|
return new Promise(resolve => {
|
||||||
safeExec('/usr/bin/podkop', ['check_logs'], 0, result => {
|
safeExec('/usr/bin/podkop', ['check_logs'], 0, result => {
|
||||||
if (!result || !result.stdout) {
|
if (!result || !result.stdout) return resolve([]);
|
||||||
console.error('No logs received from check_logs command');
|
|
||||||
return resolve([]);
|
|
||||||
}
|
|
||||||
|
|
||||||
const logs = result.stdout.split('\n');
|
const logs = result.stdout.split('\n');
|
||||||
console.log('Got logs from check_logs command, total lines:', logs.length);
|
const errors = logs.filter(log =>
|
||||||
|
log.includes('[critical]')
|
||||||
|
);
|
||||||
|
|
||||||
const errors = logs.filter(log => {
|
|
||||||
const hasCritical = log.includes('[critical]');
|
|
||||||
if (hasCritical) {
|
|
||||||
console.log('Found critical log:', log);
|
|
||||||
}
|
|
||||||
return hasCritical;
|
|
||||||
});
|
|
||||||
|
|
||||||
console.log('Found errors:', errors.length, errors);
|
|
||||||
resolve(errors);
|
resolve(errors);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -722,9 +712,7 @@ function stopDiagnosticsUpdates() {
|
|||||||
|
|
||||||
// Error polling functions
|
// Error polling functions
|
||||||
function startErrorPolling() {
|
function startErrorPolling() {
|
||||||
console.log('Starting error polling');
|
|
||||||
if (errorPollTimer) {
|
if (errorPollTimer) {
|
||||||
console.log('Clearing existing error poll timer');
|
|
||||||
clearInterval(errorPollTimer);
|
clearInterval(errorPollTimer);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -732,11 +720,9 @@ function startErrorPolling() {
|
|||||||
isInitialCheck = false;
|
isInitialCheck = false;
|
||||||
|
|
||||||
// Immediately check for errors on start
|
// Immediately check for errors on start
|
||||||
console.log('Running immediate check for errors');
|
|
||||||
checkForCriticalErrors();
|
checkForCriticalErrors();
|
||||||
|
|
||||||
// Then set up periodic checks
|
// Then set up periodic checks
|
||||||
console.log('Setting up periodic error checks with interval:', constants.ERROR_POLL_INTERVAL);
|
|
||||||
errorPollTimer = setInterval(checkForCriticalErrors, constants.ERROR_POLL_INTERVAL);
|
errorPollTimer = setInterval(checkForCriticalErrors, constants.ERROR_POLL_INTERVAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -749,39 +735,28 @@ function stopErrorPolling() {
|
|||||||
|
|
||||||
async function checkForCriticalErrors() {
|
async function checkForCriticalErrors() {
|
||||||
try {
|
try {
|
||||||
console.log('Checking for critical errors, isInitialCheck =', isInitialCheck);
|
|
||||||
const errors = await getPodkopErrors();
|
const errors = await getPodkopErrors();
|
||||||
console.log('Got errors from getPodkopErrors:', errors.length);
|
|
||||||
|
|
||||||
if (errors && errors.length > 0) {
|
if (errors && errors.length > 0) {
|
||||||
// Filter out errors we've already seen
|
// Filter out errors we've already seen
|
||||||
const newErrors = errors.filter(error => !lastErrorsSet.has(error));
|
const newErrors = errors.filter(error => !lastErrorsSet.has(error));
|
||||||
console.log('New errors not seen before:', newErrors.length);
|
|
||||||
|
|
||||||
if (newErrors.length > 0) {
|
if (newErrors.length > 0) {
|
||||||
// On initial check, just store errors without showing notifications
|
// On initial check, just store errors without showing notifications
|
||||||
if (!isInitialCheck) {
|
if (!isInitialCheck) {
|
||||||
console.log('Showing notifications for errors:', newErrors.length);
|
|
||||||
// Show each new error as a notification
|
// Show each new error as a notification
|
||||||
newErrors.forEach(error => {
|
newErrors.forEach(error => {
|
||||||
console.log('Showing notification for error:', error);
|
|
||||||
showErrorNotification(error, newErrors.length > 1);
|
showErrorNotification(error, newErrors.length > 1);
|
||||||
});
|
});
|
||||||
} else {
|
|
||||||
console.log('Initial check, not showing notifications');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add new errors to our set of seen errors
|
// Add new errors to our set of seen errors
|
||||||
newErrors.forEach(error => lastErrorsSet.add(error));
|
newErrors.forEach(error => lastErrorsSet.add(error));
|
||||||
console.log('Updated lastErrorsSet, size =', lastErrorsSet.size);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// After first check, mark as no longer initial
|
// After first check, mark as no longer initial
|
||||||
if (isInitialCheck) {
|
isInitialCheck = false;
|
||||||
console.log('Setting isInitialCheck to false');
|
|
||||||
isInitialCheck = false;
|
|
||||||
}
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error checking for critical messages:', error);
|
console.error('Error checking for critical messages:', error);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user