mirror of
https://github.com/louislam/uptime-kuma.git
synced 2024-11-23 14:54:05 +00:00
Compare commits
7 commits
1e635257dc
...
8c84ae3baf
Author | SHA1 | Date | |
---|---|---|---|
|
8c84ae3baf | ||
|
8a432ac937 | ||
|
4e667c9adb | ||
|
617634f2af | ||
|
124f5a471a | ||
|
a87b833a5a | ||
|
caa8dd8ec2 |
2 changed files with 25 additions and 7 deletions
|
@ -228,6 +228,20 @@ async function testRemoteBrowser(remoteBrowserURL) {
|
||||||
throw new Error(e.message);
|
throw new Error(e.message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cleanup function to terminate all browser processes and clear cache after each monitoring check.
|
||||||
|
* @param {import ("playwright-core").Page} page The page to close
|
||||||
|
* @returns {Promise<void>}
|
||||||
|
*/
|
||||||
|
async function cleanupBrowser(page) {
|
||||||
|
if (page) {
|
||||||
|
await page.context().clearCookies();
|
||||||
|
await page.context().clearPermissions();
|
||||||
|
await page.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
class RealBrowserMonitorType extends MonitorType {
|
class RealBrowserMonitorType extends MonitorType {
|
||||||
|
|
||||||
name = "real-browser";
|
name = "real-browser";
|
||||||
|
@ -251,7 +265,7 @@ class RealBrowserMonitorType extends MonitorType {
|
||||||
path: path.join(Database.screenshotDir, filename),
|
path: path.join(Database.screenshotDir, filename),
|
||||||
});
|
});
|
||||||
|
|
||||||
await context.close();
|
await cleanupBrowser(page); // Ensure cleanup is called after each monitoring check
|
||||||
|
|
||||||
if (res.status() >= 200 && res.status() < 400) {
|
if (res.status() >= 200 && res.status() < 400) {
|
||||||
heartbeat.status = UP;
|
heartbeat.status = UP;
|
||||||
|
|
|
@ -220,6 +220,9 @@ module.exports.statusPageSocketHandler = (socket) => {
|
||||||
|
|
||||||
// Delete groups that are not in the list
|
// Delete groups that are not in the list
|
||||||
log.debug("socket", "Delete groups that are not in the list");
|
log.debug("socket", "Delete groups that are not in the list");
|
||||||
|
if (groupIDList.length === 0) {
|
||||||
|
await R.exec("DELETE FROM `group` WHERE status_page_id = ?", [ statusPage.id ]);
|
||||||
|
} else {
|
||||||
const slots = groupIDList.map(() => "?").join(",");
|
const slots = groupIDList.map(() => "?").join(",");
|
||||||
|
|
||||||
const data = [
|
const data = [
|
||||||
|
@ -227,6 +230,7 @@ module.exports.statusPageSocketHandler = (socket) => {
|
||||||
statusPage.id
|
statusPage.id
|
||||||
];
|
];
|
||||||
await R.exec(`DELETE FROM \`group\` WHERE id NOT IN (${slots}) AND status_page_id = ?`, data);
|
await R.exec(`DELETE FROM \`group\` WHERE id NOT IN (${slots}) AND status_page_id = ?`, data);
|
||||||
|
}
|
||||||
|
|
||||||
const server = UptimeKumaServer.getInstance();
|
const server = UptimeKumaServer.getInstance();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue