Compare View
Commits (4)
Changes
Showing 3 changed files Inline Diff
config.json
File was created | 1 | {} | |
1 | {} | 2 |
heartbeat.js
1 | "use strict"; | 1 | "use strict"; |
2 | 2 | ||
3 | const request = require('request'); | 3 | const request = require('request'); |
4 | 4 | ||
5 | const config = require('./config'); | 5 | const config = require('./config'); |
6 | const logger = require('./logger'); | 6 | const logger = require('./logger'); |
7 | const matrix = require('./matrix'); | 7 | const matrix = require('./matrix'); |
8 | const core_url = require('./core-url'); | ||
8 | const core_url = require('./core-url'); | 9 | |
9 | 10 | let module_type; | |
10 | let module_type; | 11 | |
11 | 12 | function sendHeartbeat() { | |
12 | function sendHeartbeat() { | 13 | if (!config || !core_url || !module_type) { return; } |
13 | if (!config || !core_url || !module_type) { return; } | 14 | |
14 | 15 | let heartbeat_name = config.handler_name || config.origin; | |
15 | let heartbeat_name = config.handler_name || config.origin; | 16 | if (config.username) { |
16 | if (config.username) { | 17 | heartbeat_name += '/' + config.username; |
17 | heartbeat_name += '/' + config.username; | 18 | } |
18 | } | 19 | |
19 | 20 | if (!heartbeat_name) { | |
20 | if (!heartbeat_name) { | 21 | logger.warn('Unknown heartbeat name, skip sending heartbeat'); |
21 | logger.warn('Unknown heartbeat name, skip sending heartbeat'); | 22 | return; |
22 | return; | 23 | } |
23 | } | 24 | |
24 | 25 | const requestOptions = { | |
25 | const requestOptions = { | 26 | uri: core_url + '/heartbeats', |
26 | uri: core_url + '/heartbeats', | 27 | method: 'POST', |
27 | method: 'POST', | 28 | json: { |
28 | json: { | 29 | name: heartbeat_name, |
29 | name: heartbeat_name, | 30 | module_type: module_type, |
30 | module_type: module_type, | 31 | config: config, |
31 | config: config, | 32 | matrix: matrix |
32 | matrix: matrix | 33 | } |
33 | } | 34 | } |
34 | } | 35 | |
35 | 36 | request.post(requestOptions, function(err, res, body) { }); | |
36 | request.post(requestOptions, function(err, res, body) { }); | ||
37 | } | ||
38 | 37 | } | |
39 | setInterval( | 38 | |
40 | sendHeartbeat, | 39 | setInterval( |
41 | 60 * 1000 | 40 | sendHeartbeat, |
42 | ) | 41 | 60 * 1000 |
43 | 42 | ) | |
44 | function setModuleType(value) { | 43 | |
45 | logger.verbose('Set heartbeat module type as ' + value + ' and starting to send heartbeat per interval'); | 44 | function setModuleType(value) { |
46 | module_type = value; | 45 | logger.verbose('Set heartbeat module type as ' + value + ' and starting to send heartbeat per interval'); |
47 | sendHeartbeat(); | 46 | module_type = value; |
48 | } | 47 | sendHeartbeat(); |
49 | 48 | } | |
50 | exports.setModuleType = setModuleType; | 49 |
package.json
1 | { | 1 | { |
2 | "name": "komodo-sdk", | 2 | "name": "komodo-sdk", |
3 | "version": "1.23.6", | 3 | "version": "1.23.7", |
4 | "description": "SDK for Komodo", | 4 | "description": "SDK for Komodo", |
5 | "main": "index.js", | 5 | "main": "index.js", |
6 | "scripts": { | 6 | "scripts": { |
7 | "test": "mocha", | 7 | "test": "mocha", |
8 | "postversion": "git push && git push --tags" | 8 | "postversion": "git push && git push --tags" |
9 | }, | 9 | }, |
10 | "repository": { | 10 | "repository": { |
11 | "type": "git", | 11 | "type": "git", |
12 | "url": "git@gitlab.kodesumber.com:komodo/komodo-sdk.git" | 12 | "url": "git@gitlab.kodesumber.com:komodo/komodo-sdk.git" |
13 | }, | 13 | }, |
14 | "keywords": [ | 14 | "keywords": [ |
15 | "ppob", | 15 | "ppob", |
16 | "payment", | 16 | "payment", |
17 | "komodo" | 17 | "komodo" |
18 | ], | 18 | ], |
19 | "author": "Adhidarma Hadiwinoto <gua@adhisimon.org>", | 19 | "author": "Adhidarma Hadiwinoto <gua@adhisimon.org>", |
20 | "license": "ISC", | 20 | "license": "ISC", |
21 | "dependencies": { | 21 | "dependencies": { |
22 | "basic-auth": "^2.0.0", | 22 | "basic-auth": "^2.0.0", |
23 | "body-parser": "^1.18.2", | 23 | "body-parser": "^1.18.2", |
24 | "express": "^4.16.3", | 24 | "express": "^4.16.3", |
25 | "express-session": "^1.15.6", | 25 | "express-session": "^1.15.6", |
26 | "lru-cache": "^4.1.1", | 26 | "lru-cache": "^4.1.1", |
27 | "macaddress": "^0.2.8", | 27 | "macaddress": "^0.2.8", |
28 | "moment": "^2.19.1", | 28 | "moment": "^2.19.1", |
29 | "node-machine-id": "^1.1.10", | 29 | "node-machine-id": "^1.1.10", |
30 | "node-natural-sort": "^0.8.6", | 30 | "node-natural-sort": "^0.8.6", |
31 | "numeral": "^2.0.6", | 31 | "numeral": "^2.0.6", |
32 | "nunjucks": "^3.0.1", | 32 | "nunjucks": "^3.0.1", |
33 | "redis": "^2.8.0", | 33 | "redis": "^2.8.0", |
34 | "request": "^2.81.0", | 34 | "request": "^2.81.0", |
35 | "sha1": "^1.1.1", | 35 | "sha1": "^1.1.1", |
36 | "simple-git": "^1.80.1", | 36 | "simple-git": "^1.80.1", |
37 | "strftime": "^0.10.0", | 37 | "strftime": "^0.10.0", |
38 | "uniqid": "^4.1.1", | 38 | "uniqid": "^4.1.1", |
39 | "uuid": "^3.1.0", | 39 | "uuid": "^3.1.0", |
40 | "winston": "^2.3.1", | 40 | "winston": "^2.3.1", |
41 | "winston-circular-buffer": "^1.0.0", | 41 | "winston-circular-buffer": "^1.0.0", |
42 | "winston-daily-rotate-file": "^1.4.6" | 42 | "winston-daily-rotate-file": "^1.4.6" |
43 | } | 43 | } |
44 | } | 44 | } |
45 | 45 |