Commit 55f89ea9741713c8e16f7fdfd60b7c0d437d7a22
1 parent
5ac3c8e2c2
Exists in
master
smstools-util
Showing 2 changed files with 16 additions and 10 deletions Side-by-side Diff
lib/apiserver/routers/smstools.js
1 | -const childProcess = require('child_process'); | |
2 | 1 | const express = require('express'); |
3 | 2 | const config = require('komodo-sdk/config'); |
3 | +const smstoolsUtil = require('../../smstools-util'); | |
4 | 4 | const smstoolsStatus = require('../../smstools-status'); |
5 | 5 | const smstoolsStatusParsed = require('../../smstools-status-parsed'); |
6 | 6 | |
... | ... | @@ -19,15 +19,8 @@ async function pageStatusRaw(req, res) { |
19 | 19 | res.end(statusContent); |
20 | 20 | } |
21 | 21 | |
22 | -function pageRestart(req, res) { | |
23 | - const fileToExec = config.restart_smstools_wrapper || '/var/lib/smstools/centers/smstools/bin/restart-smstools'; | |
24 | - childProcess.execFile(fileToExec, (err, stdout, stderr) => { | |
25 | - res.json({ | |
26 | - err, | |
27 | - stdout, | |
28 | - stderr, | |
29 | - }); | |
30 | - }); | |
22 | +async function pageRestart(req, res) { | |
23 | + res.json(await smstoolsUtil.restart()); | |
31 | 24 | } |
32 | 25 | |
33 | 26 | router.get('/status', pageStatus); |
lib/smstools-util.js
... | ... | @@ -0,0 +1,13 @@ |
1 | +const childProcess = require('child_process'); | |
2 | +const config = require('komodo-sdk/config'); | |
3 | + | |
4 | +exports.restart = () => new Promise((resolve) => { | |
5 | + const fileToExec = config.restart_smstools_wrapper || '/var/lib/smstools/centers/smstools/bin/restart-smstools'; | |
6 | + childProcess.execFile(fileToExec, (err, stdout, stderr) => { | |
7 | + resolve({ | |
8 | + err, | |
9 | + stdout, | |
10 | + stderr, | |
11 | + }); | |
12 | + }); | |
13 | +}); |