Compare View
Commits (2)
Changes
Showing 2 changed files Side-by-side Diff
gateway/pull.js
... | ... | @@ -12,6 +12,9 @@ const core_url = require('../core-url'); |
12 | 12 | const taskArchive = require('./task-archive'); |
13 | 13 | |
14 | 14 | const MAX_SLEEP_BEFORE_RESEND_MS = 500; |
15 | +const DELAY_AFTER_NO_TASK_MS = 500; | |
16 | + | |
17 | +let is_on_delay_after_no_task = false; | |
15 | 18 | |
16 | 19 | if (config.handler_name) { |
17 | 20 | process.title = "KOMODO-GW@" + config.handler_name; |
... | ... | @@ -37,11 +40,22 @@ heartbeat.setModuleType('gateway'); |
37 | 40 | |
38 | 41 | var partner; |
39 | 42 | |
43 | +function onNoTask() { | |
44 | + is_on_delay_after_no_task = true; | |
45 | + setTimeout(function() { | |
46 | + is_on_delay_after_no_task = false; | |
47 | + }, DELAY_AFTER_NO_TASK_MS) | |
48 | +} | |
49 | + | |
40 | 50 | function setPartner(_partner) { |
41 | 51 | partner = _partner; |
42 | 52 | } |
43 | 53 | |
44 | 54 | function pullTask() { |
55 | + if (is_on_delay_after_no_task) { | |
56 | + return; | |
57 | + } | |
58 | + | |
45 | 59 | if (!partner) { |
46 | 60 | return; |
47 | 61 | } |
... | ... | @@ -79,6 +93,7 @@ function pullTask() { |
79 | 93 | logger.warn('Error pulling task from CORE', {error: error}); |
80 | 94 | } |
81 | 95 | matrix.core_is_healthy = false; |
96 | + onNoTask(); | |
82 | 97 | return; |
83 | 98 | } |
84 | 99 | |
... | ... | @@ -87,6 +102,7 @@ function pullTask() { |
87 | 102 | logger.warn('CORE http response status code for pull task is not 200', {http_response_status: response.statusCode}); |
88 | 103 | } |
89 | 104 | matrix.core_is_healthy = false; |
105 | + onNoTask(); | |
90 | 106 | return; |
91 | 107 | } |
92 | 108 | |
... | ... | @@ -96,6 +112,7 @@ function pullTask() { |
96 | 112 | matrix.core_is_healthy = true; |
97 | 113 | |
98 | 114 | if (body == 'NONE') { |
115 | + onNoTask(); | |
99 | 116 | return; |
100 | 117 | } |
101 | 118 |