Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
'use strict';
const fs = require('mz/fs');
const path = require('path');
const Subscription = require('egg').Subscription;
const BACKUP_FILE_INFIX = '-backup-';
const BACKUP_LIMIT_NUMBER = 7;
class BackupData extends Subscription {
static get schedule() {
// backup at 00:00 every day.
return {
cron: '0 0 0 * * *',
type: 'worker',
};
}
async subscribe() {
await this.removeOutdatedFiles();
const storeFile = this.ctx.app.config.sequelize.storage;
'use strict';
const Subscription = require('egg').Subscription;
class UpdateCache extends Subscription {
static get schedule() {
return {
interval: '2h',
type: 'all',
};
}
async subscribe() {
const config = this.ctx.app.config.wechat_config;
const url = config.getAccessTokenUrl.replace('APPID', config.appId).replace('APPSECRET', config.appSecret);
const res = await this.ctx.curl(url, {
dataType: 'json',
});
console.log(res.data.access_token);
'use strict';
const Subscription = require('egg').Subscription;
const now = new Date();
const start = (now.getSeconds() + 3) % 60;
class AllCron extends Subscription {
async subscribe() {
this.ctx.logger.info('all&&cron');
}
static get schedule() {
return {
cron: `${start}/30 * * * * *`,
type: 'all',
};
}
}
'use strict';
const Subscription = require('egg').Subscription;
const now = new Date();
const start = (now.getSeconds() + 3) % 60;
class WorkerCron extends Subscription {
async subscribe() {
this.ctx.logger.info('worker&&cron');
}
static get schedule() {
return {
cron: `${start}/30 * * * * *`,
type: 'worker',
};
}
}
'use strict';
const Subscription = require('egg').Subscription;
class WorkerInterval extends Subscription {
async subscribe() {
this.ctx.logger.info('all&&interval');
}
static get schedule() {
return {
interval: 3000,
type: 'worker',
};
}
}
module.exports = WorkerInterval;
'use strict';
const Subscription = require('egg').Subscription;
class AllInterval extends Subscription {
async subscribe() {
this.ctx.logger.info('all&&interval');
}
static get schedule() {
return {
interval: 3000,
type: 'all',
};
}
}
module.exports = AllInterval;