-
Notifications
You must be signed in to change notification settings - Fork 122
/
sqlite-bree.js
41 lines (34 loc) · 987 Bytes
/
sqlite-bree.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/**
* Copyright (c) Forward Email LLC
* SPDX-License-Identifier: BUSL-1.1
*/
// eslint-disable-next-line import/no-unassigned-import
require('#config/env');
const Bree = require('bree');
const Graceful = require('@ladjs/graceful');
const logger = require('#helpers/logger');
const bree = new Bree({
logger,
jobs: [
{
//
// this job cleans up any backup artifacts from 4 hr+ ago for 'rekey' and 'backup' sqlite-server cases
// (e.g. the server stopped mid-backup or an error occurred, e.g. ran out of memory)
// and in an attempt to save on disk stoarge, we will run `fs.unlink` on each of these files
// and it also updates the storage size across all aliases found
//
name: 'cleanup-sqlite',
interval: '1h',
timeout: 0
}
]
});
const graceful = new Graceful({
brees: [bree],
logger
});
graceful.listen();
(async () => {
await bree.start();
})();
logger.info('SQLite bree started', { hide_meta: true });