Commit 3e83e80449f3c8d5434705be05bae65fcb1947cf

Authored by Adhidarma Hadiwinoto
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

... ... @@ -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
... ... @@ -0,0 +1,7 @@
  1 +"use strict";
  2 +
  3 +const naturalSort = require('node-natural-sort');
  4 +
  5 +function urut(products, key) {
  6 +
  7 +}
... ... @@ -25,6 +25,7 @@
25 25 "express-session": "^1.15.6",
26 26 "lru-cache": "^4.1.1",
27 27 "moment": "^2.19.1",
  28 + "node-natural-sort": "^0.8.6",
28 29 "numeral": "^2.0.6",
29 30 "nunjucks": "^3.0.1",
30 31 "redis": "^2.8.0",