Run vacuum on sqlite periodically

This commit is contained in:
Omar Ajoue
2020-12-31 10:42:16 +01:00
parent 638310fa94
commit d528e442ba
2 changed files with 21 additions and 0 deletions

View File

@@ -12,6 +12,7 @@ import {
ActiveWorkflowRunner,
CredentialsOverwrites,
CredentialTypes,
DatabaseType,
Db,
ExternalHooks,
GenericHelpers,
@@ -156,6 +157,18 @@ export class Start extends Command {
// Wait till the database is ready
await startDbInitPromise;
const dbType = await GenericHelpers.getConfigValue('database.type') as DatabaseType;
if (dbType === 'sqlite') {
const vacuumInterval = config.get('database.sqlite.vacuumInterval') as number;
if (vacuumInterval >= 0) {
Db.collections.Execution!.query("VACUUM;");
if (vacuumInterval > 0) {
setInterval(() => Db.collections.Execution!.query("VACUUM;"), vacuumInterval * 1000);
}
}
}
if (flags.tunnel === true) {
this.log('\nWaiting for tunnel ...');