Commit a4e4646bf44293e2559e695750e7657a5ac2d4fd
1 parent
7303126883
Exists in
master
API-SERVER: services
Showing 1 changed file with 51 additions and 0 deletions Side-by-side Diff
api-server/router-services.js
... | ... | @@ -0,0 +1,51 @@ |
1 | +"use strict"; | |
2 | + | |
3 | +const express = require('express'); | |
4 | + | |
5 | +const config = require('../config'); | |
6 | +const logger = require('../logger'); | |
7 | +const matrix = require('../matrix'); | |
8 | + | |
9 | +const router = express.Router(); | |
10 | +module.exports = router; | |
11 | + | |
12 | +function isPause(req, res, next) { | |
13 | + res.json({ | |
14 | + method: '/services/is-pause', | |
15 | + error: null, | |
16 | + result: { isPause: Boolean(matrix.pause) } | |
17 | + }); | |
18 | +} | |
19 | + | |
20 | +function pause(req, res, next) { | |
21 | + matrix.pause = true; | |
22 | + res.json({ | |
23 | + method: '/services/pause', | |
24 | + error: null, | |
25 | + result: { isPause: Boolean(matrix.pause) } | |
26 | + }); | |
27 | +} | |
28 | + | |
29 | +function resume(req, res, next) { | |
30 | + matrix.pause = false; | |
31 | + res.json({ | |
32 | + method: '/services/resume', | |
33 | + error: null, | |
34 | + result: { isPause: Boolean(matrix.pause) } | |
35 | + }); | |
36 | +} | |
37 | + | |
38 | +function terminate(req, res, next) { | |
39 | + res.json({ | |
40 | + method: '/services/terminate', | |
41 | + error: null, | |
42 | + result: { | |
43 | + message: 'Going to restart in ' + delay + 'ms' | |
44 | + } | |
45 | + }) | |
46 | +} | |
47 | + | |
48 | + | |
49 | +router.get('/is-pause', isPause); | |
50 | +router.get('/pause', pause); | |
51 | +router.get('/resume', resume); |