mirror of
https://github.com/louislam/uptime-kuma.git
synced 2025-06-19 02:36:47 +02:00
Merge 69a6112d8d
into 443d5cf554
This commit is contained in:
commit
0dbafff99f
5 changed files with 32 additions and 17 deletions
4
package-lock.json
generated
4
package-lock.json
generated
|
@ -1,12 +1,12 @@
|
||||||
{
|
{
|
||||||
"name": "uptime-kuma",
|
"name": "uptime-kuma",
|
||||||
"version": "2.0.0-beta.2",
|
"version": "2.0.0-beta.3",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "uptime-kuma",
|
"name": "uptime-kuma",
|
||||||
"version": "2.0.0-beta.2",
|
"version": "2.0.0-beta.3",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@grpc/grpc-js": "~1.8.22",
|
"@grpc/grpc-js": "~1.8.22",
|
||||||
|
|
|
@ -2,13 +2,13 @@ const { MonitorType } = require("./monitor-type");
|
||||||
const { chromium } = require("playwright-core");
|
const { chromium } = require("playwright-core");
|
||||||
const { UP, log } = require("../../src/util");
|
const { UP, log } = require("../../src/util");
|
||||||
const { Settings } = require("../settings");
|
const { Settings } = require("../settings");
|
||||||
const commandExistsSync = require("command-exists").sync;
|
|
||||||
const childProcess = require("child_process");
|
const childProcess = require("child_process");
|
||||||
const path = require("path");
|
const path = require("path");
|
||||||
const Database = require("../database");
|
const Database = require("../database");
|
||||||
const jwt = require("jsonwebtoken");
|
const jwt = require("jsonwebtoken");
|
||||||
const config = require("../config");
|
const config = require("../config");
|
||||||
const { RemoteBrowser } = require("../remote-browser");
|
const { RemoteBrowser } = require("../remote-browser");
|
||||||
|
const { commandExists } = require("../util-server");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cached instance of a browser
|
* Cached instance of a browser
|
||||||
|
@ -122,7 +122,7 @@ async function prepareChromeExecutable(executablePath) {
|
||||||
executablePath = "/usr/bin/chromium";
|
executablePath = "/usr/bin/chromium";
|
||||||
|
|
||||||
// Install chromium in container via apt install
|
// Install chromium in container via apt install
|
||||||
if ( !commandExistsSync(executablePath)) {
|
if (! await commandExists(executablePath)) {
|
||||||
await new Promise((resolve, reject) => {
|
await new Promise((resolve, reject) => {
|
||||||
log.info("Chromium", "Installing Chromium...");
|
log.info("Chromium", "Installing Chromium...");
|
||||||
let child = childProcess.exec("apt update && apt --yes --no-install-recommends install chromium fonts-indic fonts-noto fonts-noto-cjk");
|
let child = childProcess.exec("apt update && apt --yes --no-install-recommends install chromium fonts-indic fonts-noto fonts-noto-cjk");
|
||||||
|
@ -146,7 +146,7 @@ async function prepareChromeExecutable(executablePath) {
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
executablePath = findChrome(allowedList);
|
executablePath = await findChrome(allowedList);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// User specified a path
|
// User specified a path
|
||||||
|
@ -160,20 +160,20 @@ async function prepareChromeExecutable(executablePath) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Find the chrome executable
|
* Find the chrome executable
|
||||||
* @param {any[]} executables Executables to search through
|
* @param {string[]} executables Executables to search through
|
||||||
* @returns {any} Executable
|
* @returns {Promise<string>} Executable
|
||||||
* @throws Could not find executable
|
* @throws {Error} Could not find executable
|
||||||
*/
|
*/
|
||||||
function findChrome(executables) {
|
async function findChrome(executables) {
|
||||||
// Use the last working executable, so we don't have to search for it again
|
// Use the last working executable, so we don't have to search for it again
|
||||||
if (lastAutoDetectChromeExecutable) {
|
if (lastAutoDetectChromeExecutable) {
|
||||||
if (commandExistsSync(lastAutoDetectChromeExecutable)) {
|
if (await commandExists(lastAutoDetectChromeExecutable)) {
|
||||||
return lastAutoDetectChromeExecutable;
|
return lastAutoDetectChromeExecutable;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (let executable of executables) {
|
for (let executable of executables) {
|
||||||
if (commandExistsSync(executable)) {
|
if (await commandExists(executable)) {
|
||||||
lastAutoDetectChromeExecutable = executable;
|
lastAutoDetectChromeExecutable = executable;
|
||||||
return executable;
|
return executable;
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,6 +77,7 @@ const SendGrid = require("./notification-providers/send-grid");
|
||||||
const YZJ = require("./notification-providers/yzj");
|
const YZJ = require("./notification-providers/yzj");
|
||||||
const SMSPlanet = require("./notification-providers/sms-planet");
|
const SMSPlanet = require("./notification-providers/sms-planet");
|
||||||
const SpugPush = require("./notification-providers/spugpush");
|
const SpugPush = require("./notification-providers/spugpush");
|
||||||
|
const { commandExists } = require("./util-server");
|
||||||
|
|
||||||
class Notification {
|
class Notification {
|
||||||
|
|
||||||
|
@ -259,12 +260,10 @@ class Notification {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if apprise exists
|
* Check if apprise exists
|
||||||
* @returns {boolean} Does the command apprise exist?
|
* @returns {Promise<boolean>} Does the command apprise exist?
|
||||||
*/
|
*/
|
||||||
static checkApprise() {
|
static async checkApprise() {
|
||||||
let commandExistsSync = require("command-exists").sync;
|
return await commandExists("apprise");
|
||||||
let exists = commandExistsSync("apprise");
|
|
||||||
return exists;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1490,7 +1490,7 @@ let needSetup = false;
|
||||||
socket.on("checkApprise", async (callback) => {
|
socket.on("checkApprise", async (callback) => {
|
||||||
try {
|
try {
|
||||||
checkLogin(socket);
|
checkLogin(socket);
|
||||||
callback(Notification.checkApprise());
|
callback(await Notification.checkApprise());
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
callback(false);
|
callback(false);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1096,3 +1096,19 @@ module.exports.axiosAbortSignal = (timeoutMs) => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* By default, command-exists will throw a null error if the command does not exist, which is ugly. The function makes it better.
|
||||||
|
* Read more: https://github.com/mathisonian/command-exists/issues/22
|
||||||
|
* @param {string} command Command to check
|
||||||
|
* @returns {Promise<boolean>} True if command exists, false otherwise
|
||||||
|
*/
|
||||||
|
async function commandExists(command) {
|
||||||
|
try {
|
||||||
|
await require("command-exists")(command);
|
||||||
|
return true;
|
||||||
|
} catch (e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
module.exports.commandExists = commandExists;
|
||||||
|
|
Loading…
Add table
Reference in a new issue