Commit fa54bb76 authored by 姜登's avatar 姜登

nitify

parent f2ca4b8e
Pipeline #4005 passed with stage
in 50 seconds
const Subscription = require('egg').Subscription;
'use strict';
class UpdateCache extends Subscription {
// 通过 schedule 属性来设置定时任务的执行间隔等配置
static get schedule() {
return {
interval: '5m', // 5分钟间隔
type: 'all', // 所有woker
immediate: true,
};
}
module.exports = {
schedule: {
interval: '5m', // 5分钟间隔
type: 'all', // 所有woker
immediate: true,
},
// subscribe 是真正定时任务执行时被运行的函数
async subscribe() {
async task(ctx) {
try {
const { ctx } = this;
const { host, customerUrl } = ctx.app.config.signatureAPI;
const notifyMap = new Map();
const ret = await ctx.curl(host + customerUrl, {
......@@ -32,9 +27,7 @@ class UpdateCache extends Subscription {
ctx.app.notifyMap = notifyMap;
}
} catch (e) {
this.ctx.logger.error('【schedule/notifyUrlTask】catch error:', JSON.stringify(e));
ctx.logger.error('【schedule/notifyUrlTask】catch error:', JSON.stringify(e));
}
}
}
module.exports = UpdateCache;
\ No newline at end of file
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment