From 1708b67949ca183b2ee86ef70e9e51c5f721a73e Mon Sep 17 00:00:00 2001 From: Louis Lam Date: Thu, 30 Nov 2023 16:12:04 +0800 Subject: [PATCH 1/7] Change execSync/spawnSync to async (#4123) * WIP * Add missing await * Update package-lock.json --- package-lock.json | 9 +++++++++ package.json | 1 + server/monitor-types/tailscale-ping.js | 7 ++----- server/notification-providers/apprise.js | 4 ++-- server/server.js | 4 ++-- server/uptime-kuma-server.js | 14 +++++++------- 6 files changed, 23 insertions(+), 16 deletions(-) diff --git a/package-lock.json b/package-lock.json index 248e64a5e..705fe812a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -63,6 +63,7 @@ "playwright-core": "~1.35.1", "prom-client": "~13.2.0", "prometheus-api-metrics": "~3.2.1", + "promisify-child-process": "~4.1.2", "protobufjs": "~7.2.4", "qs": "~6.10.4", "redbean-node": "~0.3.0", @@ -15751,6 +15752,14 @@ "node": ">=10" } }, + "node_modules/promisify-child-process": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/promisify-child-process/-/promisify-child-process-4.1.2.tgz", + "integrity": "sha512-APnkIgmaHNJpkAn7k+CrJSi9WMuff5ctYFbD0CO2XIPkM8yO7d/ShouU2clywbpHV/DUsyc4bpJCsNgddNtx4g==", + "engines": { + "node": ">=8" + } + }, "node_modules/prompts": { "version": "2.4.2", "resolved": "https://registry.npmjs.org/prompts/-/prompts-2.4.2.tgz", diff --git a/package.json b/package.json index b24f3ec21..a9db8556f 100644 --- a/package.json +++ b/package.json @@ -130,6 +130,7 @@ "playwright-core": "~1.35.1", "prom-client": "~13.2.0", "prometheus-api-metrics": "~3.2.1", + "promisify-child-process": "~4.1.2", "protobufjs": "~7.2.4", "qs": "~6.10.4", "redbean-node": "~0.3.0", diff --git a/server/monitor-types/tailscale-ping.js b/server/monitor-types/tailscale-ping.js index 3b2ac487f..1b2be2003 100644 --- a/server/monitor-types/tailscale-ping.js +++ b/server/monitor-types/tailscale-ping.js @@ -1,6 +1,6 @@ const { MonitorType } = require("./monitor-type"); const { UP } = require("../../src/util"); -const childProcess = require("child_process"); +const childProcessAsync = require("promisify-child-process"); /** * A TailscalePing class extends the MonitorType. @@ -38,12 +38,9 @@ class TailscalePing extends MonitorType { */ async runTailscalePing(hostname, interval) { let timeout = interval * 1000 * 0.8; - let res = childProcess.spawnSync("tailscale", [ "ping", hostname ], { + let res = await childProcessAsync.spawn("tailscale", [ "ping", "--c", "1", hostname ], { timeout: timeout }); - if (res.error) { - throw new Error(`Execution error: ${res.error.message}`); - } if (res.stderr && res.stderr.toString()) { throw new Error(`Error in output: ${res.stderr.toString()}`); } diff --git a/server/notification-providers/apprise.js b/server/notification-providers/apprise.js index 887afbf55..1943aaa60 100644 --- a/server/notification-providers/apprise.js +++ b/server/notification-providers/apprise.js @@ -1,5 +1,5 @@ const NotificationProvider = require("./notification-provider"); -const childProcess = require("child_process"); +const childProcessAsync = require("promisify-child-process"); class Apprise extends NotificationProvider { @@ -11,7 +11,7 @@ class Apprise extends NotificationProvider { args.push("-t"); args.push(notification.title); } - const s = childProcess.spawnSync("apprise", args); + const s = await childProcessAsync.spawn("apprise", args); const output = (s.stdout) ? s.stdout.toString() : "ERROR: maybe apprise not found"; diff --git a/server/server.js b/server/server.js index 9d509b45e..13dd16018 100644 --- a/server/server.js +++ b/server/server.js @@ -1223,9 +1223,9 @@ let needSetup = false; // Update nscd status if (previousNSCDStatus !== data.nscd) { if (data.nscd) { - server.startNSCDServices(); + await server.startNSCDServices(); } else { - server.stopNSCDServices(); + await server.stopNSCDServices(); } } diff --git a/server/uptime-kuma-server.js b/server/uptime-kuma-server.js index 6acc8d4df..28df64615 100644 --- a/server/uptime-kuma-server.js +++ b/server/uptime-kuma-server.js @@ -10,7 +10,7 @@ const util = require("util"); const { CacheableDnsHttpAgent } = require("./cacheable-dns-http-agent"); const { Settings } = require("./settings"); const dayjs = require("dayjs"); -const childProcess = require("child_process"); +const childProcessAsync = require("promisify-child-process"); const path = require("path"); // DO NOT IMPORT HERE IF THE MODULES USED `UptimeKumaServer.getInstance()`, put at the bottom of this file instead. @@ -344,7 +344,7 @@ class UptimeKumaServer { let enable = await Settings.get("nscd"); if (enable || enable === null) { - this.startNSCDServices(); + await this.startNSCDServices(); } } @@ -356,7 +356,7 @@ class UptimeKumaServer { let enable = await Settings.get("nscd"); if (enable || enable === null) { - this.stopNSCDServices(); + await this.stopNSCDServices(); } } @@ -364,11 +364,11 @@ class UptimeKumaServer { * Start all system services (e.g. nscd) * For now, only used in Docker */ - startNSCDServices() { + async startNSCDServices() { if (process.env.UPTIME_KUMA_IS_CONTAINER) { try { log.info("services", "Starting nscd"); - childProcess.execSync("sudo service nscd start", { stdio: "pipe" }); + await childProcessAsync.exec("sudo service nscd start"); } catch (e) { log.info("services", "Failed to start nscd"); } @@ -378,11 +378,11 @@ class UptimeKumaServer { /** * Stop all system services */ - stopNSCDServices() { + async stopNSCDServices() { if (process.env.UPTIME_KUMA_IS_CONTAINER) { try { log.info("services", "Stopping nscd"); - childProcess.execSync("sudo service nscd stop"); + await childProcessAsync.exec("sudo service nscd stop"); } catch (e) { log.info("services", "Failed to stop nscd"); } From 57a18958d6bbbb317bf995095051cedcd37ebae7 Mon Sep 17 00:00:00 2001 From: Louis Lam Date: Fri, 1 Dec 2023 11:42:31 +0800 Subject: [PATCH 2/7] Update gamedig from ~4.1.0 to ^4.2.0 (#4136) --- package-lock.json | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package-lock.json b/package-lock.json index 705fe812a..2d19814bd 100644 --- a/package-lock.json +++ b/package-lock.json @@ -32,7 +32,7 @@ "express-basic-auth": "~1.2.1", "express-static-gzip": "~2.1.7", "form-data": "~4.0.0", - "gamedig": "~4.1.0", + "gamedig": "^4.2.0", "html-escaper": "^3.0.3", "http-graceful-shutdown": "~3.1.7", "http-proxy-agent": "~5.0.0", @@ -10252,9 +10252,9 @@ } }, "node_modules/gamedig": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/gamedig/-/gamedig-4.1.0.tgz", - "integrity": "sha512-jvLUEakihJgpiw9t9yQRsbcemeALeTNlnaWY1gvYdwI63ZlkxznTaLqX5K/eluRTTCtAWNW3YceT6NVjyAZIwA==", + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/gamedig/-/gamedig-4.2.0.tgz", + "integrity": "sha512-UwV9gT1PrOTxjwGzj9/i8XJLx9QqmzFtrRJnRLqN7fZWEIRHjbuUpx2b6Y3v/5QyRDFP+vaB3Pm0hw3Xg4RnOQ==", "dependencies": { "cheerio": "^1.0.0-rc.10", "gbxremote": "^0.2.1", diff --git a/package.json b/package.json index a9db8556f..d1861fbb4 100644 --- a/package.json +++ b/package.json @@ -99,7 +99,7 @@ "express-basic-auth": "~1.2.1", "express-static-gzip": "~2.1.7", "form-data": "~4.0.0", - "gamedig": "~4.1.0", + "gamedig": "^4.2.0", "html-escaper": "^3.0.3", "http-graceful-shutdown": "~3.1.7", "http-proxy-agent": "~5.0.0", From cb3a104dc0ec3727015e5531d01bdf65f0e57091 Mon Sep 17 00:00:00 2001 From: Louis Lam Date: Fri, 1 Dec 2023 14:09:13 +0800 Subject: [PATCH 3/7] Default Retries from 1 to 0 (#4139) * Default "Retries" from 1 to 0 --- src/pages/EditMonitor.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/EditMonitor.vue b/src/pages/EditMonitor.vue index f83eec017..cb04f138e 100644 --- a/src/pages/EditMonitor.vue +++ b/src/pages/EditMonitor.vue @@ -860,7 +860,7 @@ const monitorDefaults = { interval: 60, retryInterval: 60, resendInterval: 0, - maxretries: 1, + maxretries: 0, timeout: 48, notificationIDList: {}, ignoreTls: false, From 1e75d81bcff7d2d16c0517f98236eda3a5dcb72d Mon Sep 17 00:00:00 2001 From: Louis Lam Date: Fri, 1 Dec 2023 14:16:35 +0800 Subject: [PATCH 4/7] Update apprise from 1.4.5 to 1.6.0 (#4140) --- docker/debian-base.dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/debian-base.dockerfile b/docker/debian-base.dockerfile index bd609830a..2be159d03 100644 --- a/docker/debian-base.dockerfile +++ b/docker/debian-base.dockerfile @@ -27,7 +27,7 @@ RUN apt-get update && \ ca-certificates \ sudo \ nscd && \ - pip3 --no-cache-dir install apprise==1.4.5 && \ + pip3 --no-cache-dir install apprise==1.6.0 && \ rm -rf /var/lib/apt/lists/* && \ apt --yes autoremove From 9fb95fe95e3a05b3436fd735a87a2072d22d7df5 Mon Sep 17 00:00:00 2001 From: Louis Lam Date: Fri, 1 Dec 2023 14:25:41 +0800 Subject: [PATCH 5/7] Add support for /snap/bin/chromium (#4141) --- server/monitor-types/real-browser-monitor-type.js | 1 + 1 file changed, 1 insertion(+) diff --git a/server/monitor-types/real-browser-monitor-type.js b/server/monitor-types/real-browser-monitor-type.js index f3e5695f8..5e5a56a00 100644 --- a/server/monitor-types/real-browser-monitor-type.js +++ b/server/monitor-types/real-browser-monitor-type.js @@ -40,6 +40,7 @@ if (process.platform === "win32") { "/usr/bin/chromium", "/usr/bin/chromium-browser", "/usr/bin/google-chrome", + "/snap/bin/chromium", // Ubuntu ]; } else if (process.platform === "darwin") { // TODO: Generated by GitHub Copilot, but not sure if it's correct From 9c9a086788f76a88dc833348eaa0fb042e9623f0 Mon Sep 17 00:00:00 2001 From: Frank Elsinga Date: Fri, 1 Dec 2023 07:34:37 +0100 Subject: [PATCH 6/7] accessible `ActionSelect`/ `ActionInput` (#4132) * made sure that the ActionSelect'or has correct accessibiltiy tags * fixed linting error * improved the ActionInputs accessibility --- src/components/ActionInput.vue | 11 +++++++++-- src/components/ActionSelect.vue | 22 ++++++++++++++++++---- src/components/settings/Notifications.vue | 6 +++--- src/lang/en.json | 4 ++++ src/pages/EditMonitor.vue | 6 +++++- 5 files changed, 39 insertions(+), 10 deletions(-) diff --git a/src/components/ActionInput.vue b/src/components/ActionInput.vue index fe3504b17..44c9e586f 100644 --- a/src/components/ActionInput.vue +++ b/src/components/ActionInput.vue @@ -8,9 +8,9 @@ :placeholder="placeholder" :disabled="!enabled" > - + @@ -66,6 +66,13 @@ export default { action: { type: Function, default: () => {}, + }, + /** + * The aria-label of the action button + */ + actionAriaLabel: { + type: String, + required: true, } }, emits: [ "update:modelValue" ], diff --git a/src/components/ActionSelect.vue b/src/components/ActionSelect.vue index 78daebc26..b163cd3a0 100644 --- a/src/components/ActionSelect.vue +++ b/src/components/ActionSelect.vue @@ -1,11 +1,11 @@ @@ -20,6 +20,13 @@ export default { type: Array, default: () => [], }, + /** + * The id of the form which will be targeted by a