Fix Uptime Kuma cannot be stopped

This commit is contained in:
Louis Lam 2022-12-08 19:13:47 +08:00
parent 2dff7dd380
commit e478084ff9
3 changed files with 10 additions and 1 deletions

View File

@ -1740,6 +1740,7 @@ async function shutdownFunction(signal) {
stopBackgroundJobs(); stopBackgroundJobs();
await cloudflaredStop(); await cloudflaredStop();
Settings.stopCacheCleaner();
} }
/** Final function called before application exits */ /** Final function called before application exits */

View File

@ -158,6 +158,13 @@ class Settings {
delete Settings.cacheList[key]; delete Settings.cacheList[key];
} }
} }
static stopCacheCleaner() {
if (Settings.cacheCleaner) {
clearInterval(Settings.cacheCleaner);
Settings.cacheCleaner = null;
}
}
} }
module.exports = { module.exports = {

View File

@ -1,6 +1,7 @@
const { checkLogin, setSetting, setting, doubleCheckPassword } = require("../util-server"); const { checkLogin, setSetting, setting, doubleCheckPassword } = require("../util-server");
const { CloudflaredTunnel } = require("node-cloudflared-tunnel"); const { CloudflaredTunnel } = require("node-cloudflared-tunnel");
const { UptimeKumaServer } = require("../uptime-kuma-server"); const { UptimeKumaServer } = require("../uptime-kuma-server");
const { log } = require("../../src/util");
const io = UptimeKumaServer.getInstance().io; const io = UptimeKumaServer.getInstance().io;
const prefix = "cloudflared_"; const prefix = "cloudflared_";
@ -107,7 +108,7 @@ module.exports.autoStart = async (token) => {
/** Stop cloudflared */ /** Stop cloudflared */
module.exports.stop = async () => { module.exports.stop = async () => {
console.log("Stop cloudflared"); log.info("cloudflared", "Stop cloudflared");
if (cloudflared) { if (cloudflared) {
cloudflared.stop(); cloudflared.stop();
} }