diff --git a/packages/app-cli/app/app.js b/packages/app-cli/app/app.js index baef949eb3..ba90091f1e 100644 --- a/packages/app-cli/app/app.js +++ b/packages/app-cli/app/app.js @@ -452,6 +452,8 @@ class Application extends BaseApplication { type: 'FOLDER_SELECT', id: Setting.value('activeFolderId'), }); + + this.startRotatingLogMaintenance(Setting.value('profileDir')); } } } diff --git a/packages/app-desktop/app.ts b/packages/app-desktop/app.ts index e4f64579d2..0fc9950614 100644 --- a/packages/app-desktop/app.ts +++ b/packages/app-desktop/app.ts @@ -566,6 +566,8 @@ class Application extends BaseApplication { await SpellCheckerService.instance().initialize(new SpellCheckerServiceDriverNative()); + this.startRotatingLogMaintenance(Setting.value('profileDir')); + // await populateDatabase(reg.db(), { // clearDatabase: true, // folderCount: 1000, diff --git a/packages/lib/BaseApplication.ts b/packages/lib/BaseApplication.ts index da944f2fca..40d95a7e74 100644 --- a/packages/lib/BaseApplication.ts +++ b/packages/lib/BaseApplication.ts @@ -735,6 +735,20 @@ export default class BaseApplication { return toSystemSlashes(output, 'linux'); } + protected startRotatingLogMaintenance(profileDir: string) { + this.rotatingLogs = new RotatingLogs(profileDir); + const processLogs = async () => { + try { + await this.rotatingLogs.cleanActiveLogFile(); + await this.rotatingLogs.deleteNonActiveLogFiles(); + } catch (error) { + appLogger.error(error); + } + }; + shim.setTimeout(() => { void processLogs(); }, 60000); + shim.setInterval(() => { void processLogs(); }, 24 * 60 * 60 * 1000); + } + public async start(argv: string[], options: StartOptions = null): Promise { options = { keychainEnabled: true, @@ -932,18 +946,6 @@ export default class BaseApplication { await MigrationService.instance().run(); - this.rotatingLogs = new RotatingLogs(profileDir); - const processLogs = async () => { - try { - await this.rotatingLogs.cleanActiveLogFile(); - await this.rotatingLogs.deleteNonActiveLogFiles(); - } catch (error) { - appLogger.error(error); - } - }; - shim.setTimeout(() => { void processLogs(); }, 60000); - shim.setInterval(() => { void processLogs(); }, 24 * 60 * 60 * 1000); - return argv; } }