mirror of
https://github.com/zadam/trilium.git
synced 2026-05-06 15:26:59 +02:00
chore(core): integrate scheduler
This commit is contained in:
@@ -198,6 +198,8 @@ async function initialize(): Promise<void> {
|
||||
console.log("[Worker] Database not initialized, skipping becca load (will be loaded during DB initialization)");
|
||||
}
|
||||
|
||||
coreModule.scheduler.startScheduler();
|
||||
|
||||
console.log("[Worker] Initialization complete");
|
||||
} catch (error) {
|
||||
initError = error instanceof Error ? error : new Error(String(error));
|
||||
|
||||
@@ -101,15 +101,13 @@ export default async function buildApp() {
|
||||
custom.register(app);
|
||||
error_handlers.register(app);
|
||||
|
||||
const { sync, consistency_checks } = await import("@triliumnext/core");
|
||||
const { sync, consistency_checks, scheduler } = await import("@triliumnext/core");
|
||||
sync.startSyncTimer();
|
||||
|
||||
await import("./services/backup.js");
|
||||
|
||||
consistency_checks.startConsistencyChecks();
|
||||
|
||||
const { startScheduler } = await import("./services/scheduler.js");
|
||||
startScheduler();
|
||||
scheduler.startScheduler();
|
||||
|
||||
erase.startScheduledCleanup();
|
||||
|
||||
|
||||
@@ -115,6 +115,7 @@ export * as becca_mocking from "./test/becca_mocking";
|
||||
export { default as markdownImportService } from "./services/import/markdown";
|
||||
|
||||
export { default as scriptService } from "./services/script";
|
||||
export * as scheduler from "./services/scheduler";
|
||||
|
||||
export async function initializeCore({ dbConfig, executionContext, crypto, zip, zipExportProviderFactory, translations, messaging, request, schema, extraAppInfo, platform, getDemoArchive }: {
|
||||
dbConfig: SqlServiceParams,
|
||||
|
||||
@@ -65,5 +65,6 @@ export default {
|
||||
encrypt,
|
||||
decrypt,
|
||||
decryptString,
|
||||
touchProtectedSession
|
||||
touchProtectedSession,
|
||||
getLastProtectedSessionOperationDate
|
||||
};
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import { protected_session, scriptService } from "@triliumnext/core";
|
||||
|
||||
import type BNote from "../becca/entities/bnote.js";
|
||||
import attributeService from "../services/attributes.js";
|
||||
import cls from "./cls.js";
|
||||
import config from "./config.js";
|
||||
import * as cls from "./context.js";
|
||||
import hiddenSubtreeService from "./hidden_subtree.js";
|
||||
import log from "./log.js";
|
||||
import { getLog } from "./log.js";
|
||||
import options from "./options.js";
|
||||
import protected_session from "./protected_session.js";
|
||||
import scriptService from "./script.js";
|
||||
import sqlInit from "./sql_init.js";
|
||||
import ws from "./ws.js";
|
||||
|
||||
@@ -14,7 +14,7 @@ function getRunAtHours(note: BNote): number[] {
|
||||
try {
|
||||
return note.getLabelValues("runAtHour").map((hour) => parseInt(hour));
|
||||
} catch (e: any) {
|
||||
log.error(`Could not parse runAtHour for note ${note.noteId}: ${e.message}`);
|
||||
getLog().error(`Could not parse runAtHour for note ${note.noteId}: ${e.message}`);
|
||||
|
||||
return [];
|
||||
}
|
||||
@@ -40,7 +40,7 @@ export function startScheduler() {
|
||||
// is also checked before importing the demo.zip, so no need to do it again.
|
||||
if (sqlInit.isDbInitialized()) {
|
||||
console.log("Checking hidden subtree.");
|
||||
sqlInit.dbReady.then(() => cls.init(() => hiddenSubtreeService.checkHiddenSubtree()));
|
||||
sqlInit.dbReady.then(() => cls.getContext().init(() => hiddenSubtreeService.checkHiddenSubtree()));
|
||||
}
|
||||
|
||||
// Periodic checks.
|
||||
@@ -76,7 +76,7 @@ function checkProtectedSessionExpiration() {
|
||||
const lastProtectedSessionOperationDate = protected_session.getLastProtectedSessionOperationDate();
|
||||
if (protected_session.isProtectedSessionAvailable() && lastProtectedSessionOperationDate && Date.now() - lastProtectedSessionOperationDate > protectedSessionTimeout * 1000) {
|
||||
protected_session.resetDataKey();
|
||||
log.info("Expiring protected session");
|
||||
getLog().info("Expiring protected session");
|
||||
ws.reloadFrontend("leaving protected session");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user