mirror of
https://github.com/zadam/trilium.git
synced 2025-10-31 18:36:30 +01:00
chore(server): integrate DB size into startup info
This commit is contained in:
@@ -197,15 +197,13 @@ function optimize() {
|
|||||||
log.info(`Optimization finished in ${Date.now() - start}ms.`);
|
log.info(`Optimization finished in ${Date.now() - start}ms.`);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getDbSize() {
|
export function getDbSize() {
|
||||||
return sql.getValue<number>("SELECT page_count * page_size / 1000 as size FROM pragma_page_count(), pragma_page_size()");
|
return sql.getValue<number>("SELECT page_count * page_size / 1000 as size FROM pragma_page_count(), pragma_page_size()");
|
||||||
}
|
}
|
||||||
|
|
||||||
function initializeDb() {
|
function initializeDb() {
|
||||||
cls.init(initDbConnection);
|
cls.init(initDbConnection);
|
||||||
|
|
||||||
log.info(`DB size: ${getDbSize()} KB`);
|
|
||||||
|
|
||||||
dbReady.then(() => {
|
dbReady.then(() => {
|
||||||
if (config.General && config.General.noBackup === true) {
|
if (config.General && config.General.noBackup === true) {
|
||||||
log.info("Disabling scheduled backups.");
|
log.info("Disabling scheduled backups.");
|
||||||
|
|||||||
@@ -482,6 +482,21 @@ export function formatUtcTime(time: string) {
|
|||||||
return time.replace("T", " ").substring(0, 19)
|
return time.replace("T", " ").substring(0, 19)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Deduplicate with client utils
|
||||||
|
export function formatSize(size: number | null | undefined) {
|
||||||
|
if (size === null || size === undefined) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
size = Math.max(Math.round(size / 1024), 1);
|
||||||
|
|
||||||
|
if (size < 1024) {
|
||||||
|
return `${size} KiB`;
|
||||||
|
} else {
|
||||||
|
return `${Math.round(size / 102.4) / 10} MiB`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
compareVersions,
|
compareVersions,
|
||||||
crash,
|
crash,
|
||||||
|
|||||||
@@ -6,11 +6,12 @@ import config from "./services/config.js";
|
|||||||
import log from "./services/log.js";
|
import log from "./services/log.js";
|
||||||
import appInfo from "./services/app_info.js";
|
import appInfo from "./services/app_info.js";
|
||||||
import ws from "./services/ws.js";
|
import ws from "./services/ws.js";
|
||||||
import utils, { formatUtcTime } from "./services/utils.js";
|
import utils, { formatSize, formatUtcTime } from "./services/utils.js";
|
||||||
import port from "./services/port.js";
|
import port from "./services/port.js";
|
||||||
import host from "./services/host.js";
|
import host from "./services/host.js";
|
||||||
import buildApp from "./app.js";
|
import buildApp from "./app.js";
|
||||||
import type { Express } from "express";
|
import type { Express } from "express";
|
||||||
|
import { getDbSize } from "./services/sql_init.js";
|
||||||
|
|
||||||
const MINIMUM_NODE_VERSION = "20.0.0";
|
const MINIMUM_NODE_VERSION = "20.0.0";
|
||||||
|
|
||||||
@@ -84,8 +85,7 @@ export default async function startTriliumServer() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function displayStartupMessage() {
|
async function displayStartupMessage() {
|
||||||
log.info("");
|
log.info("\n" + LOGO.replace("[version]", appInfo.appVersion));
|
||||||
log.info(LOGO.replace("[version]", appInfo.appVersion));
|
|
||||||
log.info(`📦 Versions: app=${appInfo.appVersion} db=${appInfo.dbVersion} sync=${appInfo.syncVersion} clipper=${appInfo.clipperProtocolVersion}`)
|
log.info(`📦 Versions: app=${appInfo.appVersion} db=${appInfo.dbVersion} sync=${appInfo.syncVersion} clipper=${appInfo.clipperProtocolVersion}`)
|
||||||
log.info(`🔧 Build: ${formatUtcTime(appInfo.buildDate)} (${appInfo.buildRevision.substring(0, 10)})`);
|
log.info(`🔧 Build: ${formatUtcTime(appInfo.buildDate)} (${appInfo.buildRevision.substring(0, 10)})`);
|
||||||
log.info(`📂 Data dir: ${appInfo.dataDirectory}`);
|
log.info(`📂 Data dir: ${appInfo.dataDirectory}`);
|
||||||
@@ -98,6 +98,7 @@ async function displayStartupMessage() {
|
|||||||
const cpuModel = (cpuInfos[0].model || "").trimEnd();
|
const cpuModel = (cpuInfos[0].model || "").trimEnd();
|
||||||
log.info(`💻 CPU: ${cpuModel} (${cpuInfos.length}-core @ ${cpuInfos[0].speed} Mhz)`);
|
log.info(`💻 CPU: ${cpuModel} (${cpuInfos.length}-core @ ${cpuInfos[0].speed} Mhz)`);
|
||||||
}
|
}
|
||||||
|
log.info(`💾 DB size: ${formatSize(getDbSize() * 1024)}`);
|
||||||
log.info("");
|
log.info("");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user