mirror of
https://github.com/koichixD/uptime-kuma.git
synced 2026-09-04 09:13:21 +00:00
fix: show actual bind address in startup logs (#6999)
Co-authored-by: Maks Pikov <mixelburg@users.noreply.github.com> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
This commit is contained in:
co-authored by
Maks Pikov
autofix-ci[bot]
parent
49f2633c9b
commit
1de276006c
@@ -985,3 +985,34 @@ async function commandExists(command) {
|
||||
}
|
||||
}
|
||||
module.exports.commandExists = commandExists;
|
||||
|
||||
/**
|
||||
* Log the server's listening URLs, similar to Vite's dev server output.
|
||||
* When no hostname is specified (bound to all interfaces), it prints
|
||||
* localhost plus every non-internal network address.
|
||||
* @param {string} tag Log tag (e.g. "server", "setup-database")
|
||||
* @param {number} port Port number
|
||||
* @param {string} hostname Bound hostname, if any
|
||||
* @returns {void}
|
||||
*/
|
||||
module.exports.printServerUrls = (tag, port, hostname) => {
|
||||
if (hostname) {
|
||||
log.info(tag, `Listening on http://${hostname}:${port}`);
|
||||
return;
|
||||
}
|
||||
|
||||
const { networkInterfaces } = require("os");
|
||||
const nets = networkInterfaces();
|
||||
|
||||
log.info(tag, "Listening on:");
|
||||
log.info(tag, ` Local: http://localhost:${port}`);
|
||||
|
||||
for (const iface of Object.values(nets)) {
|
||||
for (const addr of iface) {
|
||||
if (!addr.internal) {
|
||||
const host = addr.family === "IPv6" ? `[${addr.address}]` : addr.address;
|
||||
log.info(tag, ` Network: http://${host}:${port}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user