Compare View
Commits (2)
Changes
Showing 9 changed files Side-by-side Diff
CHANGELOG.md
... | ... | @@ -4,8 +4,14 @@ All notable changes to this project will be documented in this file. Dates are d |
4 | 4 | |
5 | 5 | Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). |
6 | 6 | |
7 | +#### [v1.43.9](https://gitlab.kodesumber.com/komodo/komodo-sdk/compare/v1.43.8...v1.43.9) | |
8 | + | |
9 | +- Migrate to tektrans-logger on api-server [`020fbb8`](https://gitlab.kodesumber.com/komodo/komodo-sdk/commit/020fbb814e3ae515b67993d3f794669e5782a803) | |
10 | + | |
7 | 11 | #### [v1.43.8](https://gitlab.kodesumber.com/komodo/komodo-sdk/compare/v1.43.7...v1.43.8) |
8 | 12 | |
13 | +> 12 October 2021 | |
14 | + | |
9 | 15 | - Bump to eslint@8.0.0 [`f85291b`](https://gitlab.kodesumber.com/komodo/komodo-sdk/commit/f85291b4e9a8135cbba6cd69e2816972aa8a64a2) |
10 | 16 | - Bump to uuid@3.4.0 [`1e478a2`](https://gitlab.kodesumber.com/komodo/komodo-sdk/commit/1e478a2ba360341e9d7ec607c45ac10383df7db8) |
11 | 17 |
api-server/index.js
... | ... | @@ -6,9 +6,9 @@ |
6 | 6 | |
7 | 7 | const express = require('express'); |
8 | 8 | const uniqid = require('uniqid'); |
9 | +const logger = require('tektrans-logger'); | |
9 | 10 | |
10 | 11 | const config = require('../config'); |
11 | -const logger = require('../logger'); | |
12 | 12 | |
13 | 13 | const requestLogger = require('./middlewares/request-logger'); |
14 | 14 |
api-server/middlewares/request-logger.js
api-server/router-config.js
... | ... | @@ -9,7 +9,6 @@ const copyFile = require('fs-copy-file'); |
9 | 9 | const moment = require('moment'); |
10 | 10 | |
11 | 11 | const config = require('../config'); |
12 | -const logger = require('../logger'); | |
13 | 12 | const matrix = require('../matrix'); |
14 | 13 | |
15 | 14 | const router = express.Router(); |
... | ... | @@ -17,16 +16,16 @@ module.exports = router; |
17 | 16 | |
18 | 17 | fs.existsSync('config-backup') || fs.mkdirSync('config-backup'); |
19 | 18 | |
20 | -function getJsonConfig(req, res, next) { | |
19 | +function getJsonConfig(req, res) { | |
21 | 20 | res.json(config); |
22 | 21 | } |
23 | 22 | |
24 | -function getConfigElement(req, res, next) { | |
23 | +function getConfigElement(req, res) { | |
25 | 24 | const key = ((req && req.params && req.params.key) ? req.params.key : '').replace(/^config\.*/, '').trim(); |
26 | 25 | res.json(jsonQuery(key, {data: config}).value); |
27 | 26 | } |
28 | 27 | |
29 | -function setConfigElement(req, res, next) { | |
28 | +function setConfigElement(req, res) { | |
30 | 29 | if (!req.body || !req.body.key || !req.body.value) { |
31 | 30 | res.end('INVALID BODY'); |
32 | 31 | return; |
... | ... | @@ -43,7 +42,7 @@ function setConfigElement(req, res, next) { |
43 | 42 | }); |
44 | 43 | } |
45 | 44 | |
46 | -function delConfigElement(req, res, next) { | |
45 | +function delConfigElement(req, res) { | |
47 | 46 | const key = ((req && req.params && req.params.key) ? req.params.key : '').replace(/^config\.*/, '').trim(); |
48 | 47 | |
49 | 48 | if (!key) { |
... | ... | @@ -60,7 +59,7 @@ function delConfigElement(req, res, next) { |
60 | 59 | }); |
61 | 60 | } |
62 | 61 | |
63 | -function saveConfig(req, res, next) { | |
62 | +function saveConfig(req, res) { | |
64 | 63 | copyFile('config.json', 'config-backup/config_' + moment().format('YYYYMMDD_HHmmss.SS') + '.json', function(err) { |
65 | 64 | if (err) { |
66 | 65 | res.json({ |
... | ... | @@ -89,7 +88,7 @@ function saveConfig(req, res, next) { |
89 | 88 | }) |
90 | 89 | } |
91 | 90 | |
92 | -function isDirty(req, res, next) { | |
91 | +function isDirty(req, res) { | |
93 | 92 | res.json({ |
94 | 93 | method: '/config/is-dirty', |
95 | 94 | error: null, |
api-server/router-locations.js
api-server/router-products.js
... | ... | @@ -5,13 +5,12 @@ const naturalSort = require('node-natural-sort'); |
5 | 5 | const unique = require('array-unique'); |
6 | 6 | |
7 | 7 | const config = require('../config'); |
8 | -const logger = require('../logger'); | |
9 | 8 | const matrix = require('../matrix'); |
10 | 9 | |
11 | 10 | const router = express.Router(); |
12 | 11 | module.exports = router; |
13 | 12 | |
14 | -function pageIndex(req, res, next) { | |
13 | +function pageIndex(req, res) { | |
15 | 14 | res.json({ |
16 | 15 | method: '/products', |
17 | 16 | error: null, |
... | ... | @@ -19,7 +18,7 @@ function pageIndex(req, res, next) { |
19 | 18 | }); |
20 | 19 | } |
21 | 20 | |
22 | -function pageAdd(req, res, next) { | |
21 | +function pageAdd(req, res) { | |
23 | 22 | let products = req.params.product || req.query.product |
24 | 23 | |
25 | 24 | if (!products) { |
... | ... | @@ -59,7 +58,7 @@ function pageAdd(req, res, next) { |
59 | 58 | }) |
60 | 59 | } |
61 | 60 | |
62 | -function pageDel(req, res, next) { | |
61 | +function pageDel(req, res) { | |
63 | 62 | let products = req.params.product || req.query.product |
64 | 63 | if (!products) { |
65 | 64 | res.json({ |
api-server/router-services.js
1 | -"use strict"; | |
1 | +const MODULE_NAME = 'API-SERVER.ROUTER-SERVICES'; | |
2 | 2 | |
3 | 3 | const express = require('express'); |
4 | +const logger = require('tektrans-logger'); | |
4 | 5 | |
5 | -const config = require('../config'); | |
6 | -const logger = require('../logger'); | |
7 | 6 | const matrix = require('../matrix'); |
8 | 7 | |
9 | 8 | const router = express.Router(); |
10 | 9 | module.exports = router; |
11 | 10 | |
12 | -function isPause(req, res, next) { | |
11 | +function isPause(req, res) { | |
13 | 12 | res.json({ |
14 | 13 | method: '/services/is-pause', |
15 | 14 | error: null, |
... | ... | @@ -17,7 +16,7 @@ function isPause(req, res, next) { |
17 | 16 | }); |
18 | 17 | } |
19 | 18 | |
20 | -function pause(req, res, next) { | |
19 | +function pause(req, res) { | |
21 | 20 | matrix.paused = true; |
22 | 21 | res.json({ |
23 | 22 | method: '/services/pause', |
... | ... | @@ -26,7 +25,7 @@ function pause(req, res, next) { |
26 | 25 | }); |
27 | 26 | } |
28 | 27 | |
29 | -function resume(req, res, next) { | |
28 | +function resume(req, res) { | |
30 | 29 | matrix.paused = false; |
31 | 30 | res.json({ |
32 | 31 | method: '/services/resume', |
... | ... | @@ -35,12 +34,21 @@ function resume(req, res, next) { |
35 | 34 | }); |
36 | 35 | } |
37 | 36 | |
38 | -function terminate(req, res, next) { | |
37 | +function terminate(req, res) { | |
38 | + const { xid } = res.locals; | |
39 | + const delay = 5000; | |
40 | + | |
39 | 41 | res.json({ |
40 | 42 | method: '/services/terminate', |
41 | 43 | error: null, |
42 | - message: 'Going to restart in ' + delay + 'ms' | |
43 | - }) | |
44 | + message: `Going to restart in ${delay} ms` | |
45 | + }); | |
46 | + | |
47 | + logger.info(`${MODULE_NAME} 9E1EC746: Got a terminate request. Going to restart`, { xid, delay }) | |
48 | + | |
49 | + setTimeout(() => { | |
50 | + process.exit(0); | |
51 | + }, delay); | |
44 | 52 | } |
45 | 53 | |
46 | 54 |
package-lock.json
1 | 1 | { |
2 | 2 | "name": "komodo-sdk", |
3 | - "version": "1.43.8", | |
3 | + "version": "1.43.9", | |
4 | 4 | "lockfileVersion": 2, |
5 | 5 | "requires": true, |
6 | 6 | "packages": { |
7 | 7 | "": { |
8 | 8 | "name": "komodo-sdk", |
9 | - "version": "1.43.8", | |
9 | + "version": "1.43.9", | |
10 | 10 | "license": "ISC", |
11 | 11 | "dependencies": { |
12 | 12 | "array-unique": "^0.3.2", |