Commit 0084bf70 authored by 李尚科's avatar 李尚科

fix

parent d9da1b71
Pipeline #12313 passed with stage
in 21 seconds
......@@ -18,6 +18,7 @@ class HuaYunPaas extends Subscription {
// subscribe 是真正定时任务执行时被运行的函数
async subscribe() {
const { ctx, app } = this;
if (['https://dev-nginx.jianbing.com'].includes(this.config.NODE_BASE_URL)) {
//用redis的setnx来实现锁机制
......@@ -27,8 +28,9 @@ class HuaYunPaas extends Subscription {
let redRes = await app.redis.setnx(lock, 1);
ctx.logger.info(JSON.stringify(redRes));
ctx.logger.info('in cron');
await app.redis.expire(lock, 2);
return;
if (Number(redRes) === 1) {
await app.redis.expire(lock, 2);
ctx.logger.info('in redis');
await this.logic();
}
......@@ -50,7 +52,7 @@ class HuaYunPaas extends Subscription {
start_time = lastOne.end_time;
}
ctx.logger.info(JSON.stringify({ start_time, now_time, start, limit }));
const result = await ctx.curl(url, { method: 'POST', contentType: 'json', dataType: 'json', timing: true, timeout: 300000, data: { start_time, now_time, start, limit } });
const result = await ctx.curl(url, { method: 'POST', contentType: 'json', dataType: 'json', timing: true, timeout: 300000, data: { start_time, end_time: now_time, start, limit } });
const ret = result.data;
ctx.logger.info(JSON.stringify({ ret }));
ctx.logger.info('get result');
......
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