-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.ts
60 lines (57 loc) · 1.81 KB
/
app.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
require('source-map-support').install();
import { logger } from "./logger/Logger";
import { config } from "./config/Config";
import { conn } from "./controller/comms/Comms";
import { eq } from "./controller/Equipment";
import { webApp } from "./web/Server";
import * as readline from 'readline';
export async function initAsync() {
return Promise.resolve()
.then(function () { config.init(); })
.then(function () { logger.init(); })
.then(function () { conn.init(); })
.then(function () { eq.init(); })
.then(function () { webApp.init(); });
}
export async function startPacketCapture(bResetLogs: boolean) {
try {
let log = config.getSection('log');
log.app.captureForReplay = true;
config.setSection('log', log);
logger.startCaptureForReplay(bResetLogs);
if (bResetLogs) {
}
}
catch (err) {
console.error(`Error starting replay: ${err.message}`);
}
}
export async function stopPacketCaptureAsync() {
let log = config.getSection('log');
log.app.captureForReplay = false;
config.setSection('log', log);
return logger.stopCaptureForReplayAsync();
}
export async function stopAsync(): Promise<void> {
try {
console.log('Shutting down open processes');
// await sys.board.virtualPumpControllers.stopAsync();
await logger.stopAsync();
await conn.stopAsync();
config.update();
}
catch (err) {
console.error(`Error stopping processes: ${err.message}`);
}
finally {
process.exit();
}
}
if (process.platform === 'win32') {
let rl = readline.createInterface({ input: process.stdin, output: process.stdout });
rl.on('SIGINT', function () { stopAsync(); });
}
else {
process.on('SIGINT', function () { return stopAsync(); });
}
initAsync();