-
Notifications
You must be signed in to change notification settings - Fork 21
/
timedTask.js
57 lines (54 loc) · 1.75 KB
/
timedTask.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/*
* 定时任务 独立进程执行
* */
require('colors');
const logger = require('./nkcModules/logger');
const updateDate = require('./settings/updateDate');
const { processId } = require('./settings/env');
const jobs = require('./timedTasks/scheduleJob');
const timedTasks = require('./timedTasks/timedTasks');
const dbStatus = require('./settings/dbStatus');
const run = async () => {
// 以下任务固定时间执行
await dbStatus.database();
jobs.updateActiveUsers(updateDate.updateActiveUsersCronStr);
jobs.clearForumAndThreadPostCount();
jobs.moveRecycleMarkThreads();
jobs.disableToDraftPosts();
jobs.clearFileCache();
jobs.preparationForumCheck();
jobs.clearVerificationData();
// 以下任务定时执行
await timedTasks.cacheActiveUsers();
await timedTasks.cacheNewUsers();
await timedTasks.clearTimeoutPageCache();
await timedTasks.updateRecommendThreads();
await timedTasks.updateHomeHotColumns();
await timedTasks.clearResourceState();
await timedTasks.initVerifiedUploadState();
await timedTasks.updateAllForumLatestThread();
await timedTasks.updateForumsMessage();
await timedTasks.modifyTimeoutApplicationForm();
await timedTasks.modifyProjectCycle();
await timedTasks.initHomeBlocksTimeout();
await timedTasks.updateShopStatus();
await timedTasks.updateCommunityContentCount();
if (process.connected) {
process.send('ready');
}
process.on('message', function (msg) {
if (msg === 'shutdown') {
logger.error(`timed task service ${processId} stopped`);
process.exit(0);
}
});
};
run()
.then(() => {
logger.info(`timed task is running`);
})
.catch((err) => {
logger.error(`timed task stopped`);
logger.error(err.stack || err.message || err);
process.exit(1);
});