mirror of
https://github.com/whyour/qinglong.git
synced 2025-05-26 00:46:07 +08:00
重启服务时自动压缩db
This commit is contained in:
parent
ecaf731ecf
commit
27f17a377a
|
@ -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++) {
|
||||
|
|
|
@ -16,11 +16,15 @@ export default class EnvService {
|
|||
});
|
||||
}
|
||||
|
||||
public getDb(): DataStore {
|
||||
return this.envDb;
|
||||
}
|
||||
|
||||
public async create(payloads: Env[]): Promise<Env[]> {
|
||||
const envs = await this.envs();
|
||||
let position = initEnvPosition;
|
||||
if (envs && envs.length > 0 && envs[envs.length - 1].position) {
|
||||
position = envs[envs.length - 1].position;
|
||||
position = envs[envs.length - 1].position as number;
|
||||
}
|
||||
const tabs = payloads.map((x) => {
|
||||
position = position / 2;
|
||||
|
|
Loading…
Reference in New Issue
Block a user