Merge branch 'hotfix/21.56.9' into master
[gitter.git] / healthcheck.js
blob21d1a884579de8a42d69d2e786ee4a861d08c559
1 'use strict';
3 const Promise = require('bluebird');
4 const request = Promise.promisify(require('request'));
6 const { config } = require('gitter-web-env');
8 const HEALTH_CHECK_URLS = [config.get('basepath')];
10 HEALTH_CHECK_URLS.forEach(healthCheckUrl => {
11   request({
12     method: 'GET',
13     uri: healthCheckUrl
14   })
15     .then(res => {
16       // eslint-disable-next-line no-console
17       console.log(`STATUS ${healthCheckUrl}: ${res.statusCode}`);
18       if (res.statusCode === 200) {
19         process.exit(0);
20       } else {
21         process.exit(1);
22       }
23     })
24     .catch(err => {
25       // eslint-disable-next-line no-console
26       console.error(`Error while trying to connect to ${healthCheckUrl}:`, err, err.stack);
27       process.exit(1);
28     });
29 });