Commit 3e83e80449f3c8d5434705be05bae65fcb1947cf
1 parent
6667f3a7af
Exists in
master
resendReport digunakan jika gagal report ke core
Showing 3 changed files with 14 additions and 2 deletions Side-by-side Diff
gateway/pull.js
... | ... | @@ -10,6 +10,8 @@ const heartbeat = require('../heartbeat'); |
10 | 10 | |
11 | 11 | const taskArchive = require('./task-archive'); |
12 | 12 | |
13 | +const MAX_SLEEP_BEFORE_RESEND_MS = 500; | |
14 | + | |
13 | 15 | if (config.handler_name) { |
14 | 16 | process.title = "KOMODO-GW@" + config.handler_name; |
15 | 17 | } |
... | ... | @@ -148,9 +150,11 @@ function report(data) { |
148 | 150 | request.post(options, function(error, response, body) { |
149 | 151 | if (error) { |
150 | 152 | logger.warn('Error reporting to CORE', {error: error}); |
153 | + resendReport(data); | |
151 | 154 | } |
152 | 155 | else if (response.statusCode != 200) { |
153 | - logger.warn('CORE http response status is not 200', {requestOptions: options, http_response_status: response.statusCode}); | |
156 | + logger.warn('Error reporting to CORE, http response status is not 200', {requestOptions: options, http_response_status: response.statusCode}); | |
157 | + resendReport(data); | |
154 | 158 | } |
155 | 159 | else if (!config.do_not_verbose_log_report) { |
156 | 160 | logger.verbose('Report has been sent to CORE', {requestOptions: options}); |
... | ... | @@ -159,7 +163,7 @@ function report(data) { |
159 | 163 | } |
160 | 164 | |
161 | 165 | function resendReport(data) { |
162 | - let sleepBeforeResend = 1000; | |
166 | + const sleepBeforeResend = Math.round(Math.random() * MAX_SLEEP_BEFORE_RESEND_MS) | |
163 | 167 | logger.verbose('Resend report to CORE in ' + sleepBeforeResend + 'ms') |
164 | 168 | |
165 | 169 | setTimeout( |
misc/product-sort.js