0
0
mirror of https://github.com/louislam/uptime-kuma.git synced 2024-11-24 19:56:56 +01:00
uptime-kuma/server/jobs/incremental-vacuum.js

28 lines
840 B
JavaScript
Raw Normal View History

const { R } = require("redbean-node");
const { log } = require("../../src/util");
2023-08-09 15:05:15 +02:00
const Database = require("../database");
/**
* Run incremental_vacuum and checkpoint the WAL.
* @return {Promise<void>} A promise that resolves when the process is finished.
*/
const incrementalVacuum = async () => {
try {
2023-08-09 15:05:15 +02:00
if (Database.dbConfig.type !== "sqlite") {
log.debug("incrementalVacuum", "Skipping incremental_vacuum, not using SQLite.");
return;
}
log.debug("incrementalVacuum", "Running incremental_vacuum and wal_checkpoint(PASSIVE)...");
await R.exec("PRAGMA incremental_vacuum(200)");
await R.exec("PRAGMA wal_checkpoint(PASSIVE)");
} catch (e) {
log.error("incrementalVacuum", `Failed: ${e.message}`);
}
};
module.exports = {
incrementalVacuum,
};