重启服务时自动压缩db

This commit is contained in:
hanhh
2021-09-29 21:40:35 +08:00
parent ecaf731ecf
commit 27f17a377a
2 changed files with 11 additions and 2 deletions
+6 -1
View File
@@ -26,6 +26,11 @@ export default async () => {
const cronService = Container.get(CronService);
const envService = Container.get(EnvService);
const cronDb = cronService.getDb();
const envDb = cronService.getDb();
// compaction data file
cronDb.persistence.compactDatafile();
envDb.persistence.compactDatafile();
cronDb.count({}, async (err, count) => {
if (count === 0) {
@@ -92,7 +97,7 @@ export default async () => {
};
function randomSchedule(from: number, to: number) {
const result = [];
const result: any[] = [];
const arr = [...Array(from).keys()];
let count = arr.length;
for (let i = 0; i < to; i++) {