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 { module.exports = {
// 通过 schedule 属性来设置定时任务的执行间隔等配置 schedule: {
static get schedule() {
return {
interval: '5m', // 5分钟间隔 interval: '5m', // 5分钟间隔
type: 'all', // 所有woker type: 'all', // 所有woker
immediate: true, immediate: true,
}; },
}
// subscribe 是真正定时任务执行时被运行的函数 async task(ctx) {
async subscribe() {
try { try {
const { ctx } = this;
const { host, customerUrl } = ctx.app.config.signatureAPI; const { host, customerUrl } = ctx.app.config.signatureAPI;
const notifyMap = new Map(); const notifyMap = new Map();
const ret = await ctx.curl(host + customerUrl, { const ret = await ctx.curl(host + customerUrl, {
...@@ -32,9 +27,7 @@ class UpdateCache extends Subscription { ...@@ -32,9 +27,7 @@ class UpdateCache extends Subscription {
ctx.app.notifyMap = notifyMap; ctx.app.notifyMap = notifyMap;
} }
} catch (e) { } catch (e) {
this.ctx.logger.error('【schedule/notifyUrlTask】catch error:', JSON.stringify(e)); ctx.logger.error('【schedule/notifyUrlTask】catch error:', JSON.stringify(e));
} }
} }
} }
\ No newline at end of file
module.exports = UpdateCache;
\ 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