-
-
Notifications
You must be signed in to change notification settings - Fork 7
/
healthcheck.js
34 lines (27 loc) · 896 Bytes
/
healthcheck.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
// Copyright (C) 2017-2022 BinaryMist Limited. All rights reserved.
// Use of this software is governed by the Business Source License
// included in the file /licenses/bsl.md
// As of the Change Date specified in that file, in accordance with
// the Business Source License, use of this software will be governed
// by the Apache License, Version 2.0
import http from 'http';
import 'convict';
import config from './config/config.js';
const options = {
host: config.get('host.host'),
port: config.get('host.port'),
path: '/status',
timeout: 2000
};
/* eslint-disable no-console */
const request = http.request(options, (res) => {
console.log(`StatusCode: ${res.statusCode}`);
if (res.statusCode === 200) process.exit(0);
process.exit(1);
});
request.on('error', (err) => {
console.log(`ERROR: ${err}`);
process.exit(1);
});
/* eslint-enable no-console */
request.end();