mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-24 04:04:06 -08:00
Run vacuum on sqlite periodically
This commit is contained in:
parent
638310fa94
commit
d528e442ba
|
@ -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 ...');
|
||||
|
||||
|
|
|
@ -124,6 +124,14 @@ const config = convict({
|
|||
env: 'DB_MYSQLDB_USER',
|
||||
},
|
||||
},
|
||||
sqlite: {
|
||||
vacuumInterval: {
|
||||
doc: 'SQLite Vacuum operation interval',
|
||||
format: Number,
|
||||
default: 86400, // Given in seconds; -1 disables. 0 executes only at startup.
|
||||
env: 'DB_SQLITE_VACUUM_INTERVAL',
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
credentials: {
|
||||
|
|
Loading…
Reference in a new issue