3
这是定时任务:
"use strict";
const Subscription = require("egg").Subscription;
class GetProxyIPs extends Subscription {
static get schedule() {
return {
interval: "30s",
type: "all",
immediate: false,
disable: false
};
}
async subscribe() {
//http://35.245.208.185:3128
console.log('start proxy');
const result = await this.ctx.service.api.smth.proxy_ip_pool.getIPs();
console.log(result);
}
}
module.exports = GetProxyIPs;
这是service:
"use strict";
const Service = require("egg").Service;
class ProxyIPPoolService extends Service {
async getIPs() {
console.log('get ip');
const result = await this.app.mysql.insert("ip", {
address: "35.245.208.185",
port: "3128",
protocal: "http"
});
return result;
}
async checkIP(ip) {}
async saveIP(ip) {}
async deleteIP(ip) {}
}
module.exports=ProxyIPPoolService;
现在问题是:定时任务里的’start proxy‘可以打印出来,但是service里getIPs()里的’get ip‘,没有打印出来,应该是函数没有执行,请问一下这是什么问题?