From e478084ff99071017f1d0dbbd8d29de689ce3f14 Mon Sep 17 00:00:00 2001 From: Louis Lam Date: Thu, 8 Dec 2022 19:13:47 +0800 Subject: [PATCH] Fix Uptime Kuma cannot be stopped --- server/server.js | 1 + server/settings.js | 7 +++++++ server/socket-handlers/cloudflared-socket-handler.js | 3 ++- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/server/server.js b/server/server.js index 033b85b2..78f98910 100644 --- a/server/server.js +++ b/server/server.js @@ -1740,6 +1740,7 @@ async function shutdownFunction(signal) { stopBackgroundJobs(); await cloudflaredStop(); + Settings.stopCacheCleaner(); } /** Final function called before application exits */ diff --git a/server/settings.js b/server/settings.js index 512c20e6..285b626b 100644 --- a/server/settings.js +++ b/server/settings.js @@ -158,6 +158,13 @@ class Settings { delete Settings.cacheList[key]; } } + + static stopCacheCleaner() { + if (Settings.cacheCleaner) { + clearInterval(Settings.cacheCleaner); + Settings.cacheCleaner = null; + } + } } module.exports = { diff --git a/server/socket-handlers/cloudflared-socket-handler.js b/server/socket-handlers/cloudflared-socket-handler.js index efb1f065..ee58e1ad 100644 --- a/server/socket-handlers/cloudflared-socket-handler.js +++ b/server/socket-handlers/cloudflared-socket-handler.js @@ -1,6 +1,7 @@ const { checkLogin, setSetting, setting, doubleCheckPassword } = require("../util-server"); const { CloudflaredTunnel } = require("node-cloudflared-tunnel"); const { UptimeKumaServer } = require("../uptime-kuma-server"); +const { log } = require("../../src/util"); const io = UptimeKumaServer.getInstance().io; const prefix = "cloudflared_"; @@ -107,7 +108,7 @@ module.exports.autoStart = async (token) => { /** Stop cloudflared */ module.exports.stop = async () => { - console.log("Stop cloudflared"); + log.info("cloudflared", "Stop cloudflared"); if (cloudflared) { cloudflared.stop(); }