-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
47 lines (40 loc) · 1.15 KB
/
app.js
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
const configIt = require('@hkube/config');
const NodejsWrapper = require('@hkube/nodejs-wrapper');
const init = async () => {
try {
const { config } = configIt.load({ cwd: __dirname });
_handleErrors();
nodejsWrapper = new NodejsWrapper();
nodejsWrapper.loadAlgorithm(config.algorithm);
nodejsWrapper.connectToWorker(config.socket);
}
catch (error) {
_onInitFailed(error);
}
}
const _onInitFailed = (error) => {
console.error(error.message);
console.error(error);
process.exit(1);
}
const _handleErrors = () => {
process.on('exit', (code) => {
console.info('exit' + (code ? ' code ' + code : ''));
});
process.on('SIGINT', () => {
console.info('SIGINT');
process.exit(1);
});
process.on('SIGTERM', () => {
console.info('SIGTERM');
process.exit(1);
});
process.on('unhandledRejection', (error) => {
console.error('unhandledRejection: ' + error.message);
});
process.on('uncaughtException', (error) => {
console.error('uncaughtException: ' + error.message);
process.exit(1);
});
}
init();