Merge branch '1.23.X' into 1.23.X-merge-to-2.X.X-2

# Conflicts:
#	docker/debian-base.dockerfile
This commit is contained in:
Louis Lam
2023-12-01 15:50:35 +08:00
13 changed files with 77 additions and 34 deletions

View File

@@ -43,6 +43,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") {
allowedList = [

View File

@@ -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.
@@ -37,12 +37,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()}`);
}

View File

@@ -1,5 +1,5 @@
const NotificationProvider = require("./notification-provider");
const childProcess = require("child_process");
const childProcessAsync = require("promisify-child-process");
class Apprise extends NotificationProvider {
@@ -14,7 +14,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";

View File

@@ -1335,9 +1335,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();
}
}

View File

@@ -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");
const axios = require("axios");
// DO NOT IMPORT HERE IF THE MODULES USED `UptimeKumaServer.getInstance()`, put at the bottom of this file instead.
@@ -372,7 +372,7 @@ class UptimeKumaServer {
let enable = await Settings.get("nscd");
if (enable || enable === null) {
this.startNSCDServices();
await this.startNSCDServices();
}
}
@@ -384,7 +384,7 @@ class UptimeKumaServer {
let enable = await Settings.get("nscd");
if (enable || enable === null) {
this.stopNSCDServices();
await this.stopNSCDServices();
}
}
@@ -393,11 +393,11 @@ class UptimeKumaServer {
* For now, only used in Docker
* @returns {void}
*/
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");
}
@@ -408,11 +408,11 @@ class UptimeKumaServer {
* Stop all system services
* @returns {void}
*/
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");
}