add UPTIME_KUMA_HOST, UPTIME_KUMA_PORT and special handling for FreeBSD

pull/675/head
Louis Lam 3 years ago
parent 3fe3450533
commit f75c9e4f0c

@ -4,10 +4,7 @@ const net = require("net");
const spawn = require("child_process").spawn; const spawn = require("child_process").spawn;
const events = require("events"); const events = require("events");
const fs = require("fs"); const fs = require("fs");
const WIN = /^win/.test(process.platform); const { MAC, FBSD, LIN, WIN } = require("./util-server");
const LIN = /^linux/.test(process.platform);
const MAC = /^darwin/.test(process.platform);
const FBSD = /^freebsd/.test(process.platform);
module.exports = Ping; module.exports = Ping;

@ -43,7 +43,7 @@ console.log("Importing this project modules");
debug("Importing Monitor"); debug("Importing Monitor");
const Monitor = require("./model/monitor"); const Monitor = require("./model/monitor");
debug("Importing Settings"); debug("Importing Settings");
const { getSettings, setSettings, setting, initJWTSecret, checkLogin, startUnitTest } = require("./util-server"); const { getSettings, setSettings, setting, initJWTSecret, checkLogin, startUnitTest, FBSD } = require("./util-server");
debug("Importing Notification"); debug("Importing Notification");
const { Notification } = require("./notification"); const { Notification } = require("./notification");
@ -61,12 +61,22 @@ console.info("Version: " + checkVersion.version);
// If host is omitted, the server will accept connections on the unspecified IPv6 address (::) when IPv6 is available and the unspecified IPv4 address (0.0.0.0) otherwise. // If host is omitted, the server will accept connections on the unspecified IPv6 address (::) when IPv6 is available and the unspecified IPv4 address (0.0.0.0) otherwise.
// Dual-stack support for (::) // Dual-stack support for (::)
const hostname = args.host || process.env.HOST; let hostname = process.env.UPTIME_KUMA_HOST || args.host;
const port = parseInt(args.port || process.env.PORT || 3001);
// Also read HOST if not FreeBSD, as HOST is a system environment variable in FreeBSD
if (!hostname && !FBSD) {
hostname = process.env.HOST;
}
if (hostname) {
console.log("Custom hostname: " + hostname);
}
const port = parseInt(process.env.UPTIME_KUMA_PORT || process.env.PORT || args.port || 3001);
// SSL // SSL
const sslKey = process.env.SSL_KEY || args["ssl-key"] || undefined; const sslKey = process.env.UPTIME_KUMA_SSL_KEY || process.env.SSL_KEY || args["ssl-key"] || undefined;
const sslCert = process.env.SSL_CERT || args["ssl-cert"] || undefined; const sslCert = process.env.UPTIME_KUMA_SSL_CERT || process.env.SSL_CERT || args["ssl-cert"] || undefined;
/** /**
* Run unit test after the server is ready * Run unit test after the server is ready

@ -7,6 +7,12 @@ const dayjs = require("dayjs");
const { Resolver } = require("dns"); const { Resolver } = require("dns");
const child_process = require("child_process"); const child_process = require("child_process");
// From ping-lite
exports.WIN = /^win/.test(process.platform);
exports.LIN = /^linux/.test(process.platform);
exports.MAC = /^darwin/.test(process.platform);
exports.FBSD = /^freebsd/.test(process.platform);
/** /**
* Init or reset JWT secret * Init or reset JWT secret
* @returns {Promise<Bean>} * @returns {Promise<Bean>}

Loading…
Cancel
Save