Compare View
Commits (2)
Changes
Showing 3 changed files Inline Diff
control-panel/lib/router-main.js
1 | "use strict"; | 1 | "use strict"; |
2 | 2 | ||
3 | const module_name = 'CONTROL_PANEL_' + require('path').basename(__filename); | 3 | const module_name = 'CONTROL_PANEL_' + require('path').basename(__filename); |
4 | 4 | ||
5 | const os = require('os'); | 5 | const os = require('os'); |
6 | 6 | ||
7 | const express = require('express'); | 7 | const express = require('express'); |
8 | const router = express.Router(); | 8 | const router = express.Router(); |
9 | 9 | ||
10 | const numeral = require('numeral'); | 10 | const numeral = require('numeral'); |
11 | 11 | ||
12 | const logger = require('komodo-sdk/logger'); | 12 | const logger = require('komodo-sdk/logger'); |
13 | const matrix = require('komodo-sdk/matrix'); | 13 | const matrix = require('komodo-sdk/matrix'); |
14 | 14 | ||
15 | const misc = require('./misc'); | 15 | const misc = require('./misc'); |
16 | 16 | ||
17 | function pageMain(req, res, next) { | 17 | function pageMain(req, res, next) { |
18 | res.redirect('/runtime'); | 18 | res.redirect('/runtime'); |
19 | } | 19 | } |
20 | 20 | ||
21 | function pageLog(req, res, next) { | 21 | function pageLog(req, res, next) { |
22 | logger.query({json: true, order: 'desc'}, function(err, results) { | 22 | logger.query({json: true, order: 'desc'}, function(err, results) { |
23 | if (err) { | 23 | if (err) { |
24 | return res.end('INVALID LOGGER'); | 24 | return res.end('INVALID LOGGER'); |
25 | } | 25 | } |
26 | 26 | ||
27 | res.render( | 27 | res.render( |
28 | req.app.locals.cp_views_dir + '/log.html', | 28 | req.app.locals.cp_views_dir + '/log.html', |
29 | { | 29 | { |
30 | log: JSON.stringify(results.logs, null, 4) | 30 | log: JSON.stringify(results.logs, null, 4) |
31 | } | 31 | } |
32 | ); | 32 | ); |
33 | 33 | ||
34 | }); | 34 | }); |
35 | } | 35 | } |
36 | function pageRuntime(req, res, next) { | 36 | function pageRuntime(req, res, next) { |
37 | 37 | ||
38 | res.render( | 38 | res.render( |
39 | req.app.locals.cp_views_dir + '/runtime.html', | 39 | req.app.locals.cp_views_dir + '/runtime.html', |
40 | { | 40 | { |
41 | uptime: numeral(process.uptime()).format(), | 41 | uptime: numeral(process.uptime()).format(), |
42 | matrix: JSON.stringify(matrix, null, 4), | ||
42 | matrix: JSON.stringify(matrix, null, 4), | 43 | memory_usage: JSON.stringify(process.memoryUsage(), null, 4), |
43 | memory_usage: JSON.stringify(process.memoryUsage(), null, 4), | 44 | os_info: JSON.stringify({ |
44 | os_info: JSON.stringify({ | 45 | uptime: os.uptime(), |
45 | uptime: os.uptime(), | 46 | loadavg: os.loadavg(), |
46 | loadavg: os.loadavg(), | 47 | hostname: os.hostname(), |
47 | hostname: os.hostname(), | 48 | type: os.type(), |
48 | type: os.type(), | 49 | platform: os.platform(), |
49 | platform: os.platform(), | 50 | arch: os.arch(), |
50 | arch: os.arch(), | 51 | release: os.release(), |
51 | release: os.release(), | 52 | totalmem: os.totalmem(), |
52 | totalmem: os.totalmem(), | 53 | }, null, 4), |
53 | }, null, 4), | 54 | } |
54 | } | 55 | ) |
55 | ) | 56 | } |
56 | } | 57 | |
57 | 58 | function pageTerminate(req, res) { | |
58 | function pageTerminate(req, res) { | 59 | res.end('Terminating....', function() { |
59 | res.end('Terminating....', function() { | 60 | process.exit(0); |
60 | process.exit(0); | 61 | }); |
61 | }); | 62 | } |
62 | } | 63 | |
63 | 64 | //router.use(misc.needAuthUser); | |
64 | //router.use(misc.needAuthUser); | 65 | |
65 | 66 | router.get('/', pageMain); | |
66 | router.get('/', pageMain); | 67 | router.get('/runtime', misc.needAuthUser, pageRuntime); |
67 | router.get('/runtime', misc.needAuthUser, pageRuntime); | 68 | router.get('/log', misc.needAuthUser, pageLog); |
68 | router.get('/log', misc.needAuthUser, pageLog); | 69 | router.get('/terminate', misc.needAuthUser, pageTerminate); |
69 | router.get('/terminate', misc.needAuthUser, pageTerminate); | 70 | router.get('/restart', misc.needAuthUser, pageTerminate); |
70 | router.get('/restart', misc.needAuthUser, pageTerminate); | 71 | |
71 | 72 | module.exports = router; | |
72 | module.exports = router; | 73 |
control-panel/views/runtime.html
1 | {% extends cp_views_dir + "/template.html" %} | 1 | {% extends cp_views_dir + "/template.html" %} |
2 | 2 | ||
3 | {% block content %} | 3 | {% block content %} |
4 | 4 | ||
5 | <div class="panel panel-default"> | 5 | <div class="panel panel-default"> |
6 | <div class="panel-body"> | 6 | <div class="panel-body"> |
7 | Umur proses: {{ uptime }} detik. | 7 | Umur proses: {{ uptime }} detik. |
8 | </div> | 8 | </div> |
9 | </div> | 9 | </div> |
10 | 10 | ||
11 | {% if matrix %} | ||
12 | <h2 id="matrix">The Matrix</h2> | ||
13 | <pre>{{ matrix }}</pre> | ||
14 | {% endif %} | ||
15 | |||
11 | {% if matrix %} | 16 | <h2 id="memory_usage">Pemakaian Memori</h2> |
12 | <h2 id="matrix">The Matrix</h2> | 17 | <pre>{{ memory_usage }}</pre> |
13 | <pre>{{ matrix }}</pre> | 18 | |
14 | {% endif %} | 19 | <h2 id="os_info">Sistem Operasi</h2> |
15 | 20 | <pre>{{ os_info }}</pre> | |
16 | <h2 id="memory_usage">Pemakaian Memori</h2> | 21 | |
17 | <pre>{{ memory_usage }}</pre> | 22 | {% endblock %} |
18 | 23 |
package.json
1 | { | 1 | { |
2 | "name": "komodo-sdk", | 2 | "name": "komodo-sdk", |
3 | "version": "1.10.5", | 3 | "version": "1.10.6", |
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.2", | 24 | "express": "^4.16.2", |
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 | "moment": "^2.19.1", | 27 | "moment": "^2.19.1", |
28 | "numeral": "^2.0.6", | 28 | "numeral": "^2.0.6", |
29 | "nunjucks": "^3.0.1", | 29 | "nunjucks": "^3.0.1", |
30 | "request": "^2.81.0", | 30 | "request": "^2.81.0", |
31 | "simple-git": "^1.80.1", | 31 | "simple-git": "^1.80.1", |
32 | "strftime": "^0.10.0", | 32 | "strftime": "^0.10.0", |
33 | "uniqid": "^4.1.1", | 33 | "uniqid": "^4.1.1", |
34 | "uuid": "^3.1.0", | 34 | "uuid": "^3.1.0", |
35 | "winston": "^2.3.1", | 35 | "winston": "^2.3.1", |
36 | "winston-circular-buffer": "^1.0.0", | 36 | "winston-circular-buffer": "^1.0.0", |
37 | "winston-daily-rotate-file": "^1.4.6" | 37 | "winston-daily-rotate-file": "^1.4.6" |
38 | } | 38 | } |
39 | } | 39 | } |
40 | 40 |