-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
741eeb7
commit 34b7225
Showing
10 changed files
with
117 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,58 @@ | ||
'use strict'; | ||
|
||
const router = require('express').Router(); | ||
const healthcheck = require('@hmcts/nodejs-healthcheck'); | ||
const os = require('os'); | ||
const gitProperties = require('git.properties'); | ||
const commonContent = require('app/resources/en/translation/common'); | ||
const gitRevision = process.env.GIT_REVISION; | ||
const config = require('config'); | ||
const outputs = require('@hmcts/nodejs-healthcheck/healthcheck/outputs'); | ||
const getStore = require('app/components/utils').getStore; | ||
const session = require('express-session'); | ||
const logger = require('app/components/logger')('init'); | ||
|
||
const osHostname = os.hostname(); | ||
const gitProperties = require('git.properties'); | ||
const gitCommitId = gitProperties.git.commit.id; | ||
const config = require('config'); | ||
const gitRevision = process.env.GIT_REVISION; | ||
|
||
const healthOptions = message => { | ||
return { | ||
callback: (error, res) => { | ||
if (error) { | ||
logger.error(null, 'health_check_error', message, error); | ||
} | ||
return !error && res.status === 200 ? outputs.up() : outputs.down(error); | ||
}, | ||
timeout: config.health.timeout, | ||
deadline: config.health.deadline | ||
}; | ||
}; | ||
|
||
const sessionStore = getStore(config.redis, session); | ||
const checks = { | ||
'pcq-backend': healthcheck.web(`${config.services.pcqBackend.url}/health`, | ||
healthOptions('Health check failed on pcq-backend:') | ||
) | ||
}; | ||
if (sessionStore.constructor.name === 'RedisStore') { | ||
checks.redis = healthcheck.raw(() => { | ||
return sessionStore.client.status === 'ready' ? healthcheck.up() : healthcheck.down(); | ||
}); | ||
} | ||
|
||
router.get(`${config.app.basePath}/health`, (req, res) => { | ||
res.json({ | ||
name: commonContent.serviceName, | ||
status: 'UP', | ||
uptime: process.uptime(), | ||
host: osHostname, | ||
version: gitRevision, | ||
gitCommitId | ||
const setup = app => { | ||
healthcheck.addTo(app, { | ||
checks: checks, | ||
buildInfo: { | ||
name: config.service.name, | ||
host: os.hostname(), | ||
uptime: process.uptime(), | ||
version: gitRevision, | ||
gitCommitId | ||
} | ||
}); | ||
}); | ||
}; | ||
|
||
module.exports = router; | ||
module.exports.osHostname = osHostname; | ||
module.exports.gitCommitId = gitCommitId; | ||
module.exports = { | ||
setup: setup, | ||
osHostname: osHostname, | ||
gitCommitId: gitCommitId | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,6 +46,15 @@ | |
lodash.mergewith "^4.6.2" | ||
webdriverio "^5.15.2" | ||
|
||
"@hmcts/nodejs-healthcheck@^1.6.0": | ||
version "1.6.0" | ||
resolved "https://registry.yarnpkg.com/@hmcts/nodejs-healthcheck/-/nodejs-healthcheck-1.6.0.tgz#ecc2002f2617b207c0cc48c6c11198e53fc8bb68" | ||
integrity sha512-i9PsSbbZoI7fghnVNi6sWnwvWnJdTtEz0ytBuCogpLOVQLpeMh1FTub79AxAxIdJIvpS/s6lyGg5U+gk2mdhxA== | ||
dependencies: | ||
"@hmcts/nodejs-logging" "^3.0.1" | ||
js-yaml "^3.8.4" | ||
superagent "5" | ||
|
||
"@hmcts/nodejs-logging@^3.0.0": | ||
version "3.0.0" | ||
resolved "https://registry.yarnpkg.com/@hmcts/nodejs-logging/-/nodejs-logging-3.0.0.tgz#81d84cea5528fa57b4162641b427233fca771715" | ||
|
@@ -55,6 +64,15 @@ | |
on-finished "^2.3.0" | ||
winston "^2.4.1" | ||
|
||
"@hmcts/nodejs-logging@^3.0.1": | ||
version "3.0.1" | ||
resolved "https://registry.yarnpkg.com/@hmcts/nodejs-logging/-/nodejs-logging-3.0.1.tgz#370bfee6c1d502ea7fec13001632bb03f15d072d" | ||
integrity sha512-BpOBBFvUfy3d/pGi/s0s2CxtNwnLEm1hJcsEH7av9NpXaGL1rO0zfAcEk4eKNKYZVBEoiyXlpajFtAutSAFWfg== | ||
dependencies: | ||
moment "^2.19.3" | ||
on-finished "^2.3.0" | ||
winston "^2.4.1" | ||
|
||
"@hmcts/properties-volume@^0.0.9": | ||
version "0.0.9" | ||
resolved "https://registry.yarnpkg.com/@hmcts/properties-volume/-/properties-volume-0.0.9.tgz#1c2b29a563fcad9041231442476a4a3b7a8abf7d" | ||
|
@@ -1429,7 +1447,7 @@ colors@^1.1.2: | |
resolved "https://registry.yarnpkg.com/colors/-/colors-1.3.3.tgz#39e005d546afe01e01f9c4ca8fa50f686a01205d" | ||
integrity sha512-mmGt/1pZqYRjMxB1axhTo16/snVZ5krrKkcmMeVKxzECMMXoCgnvTPp10QgHfcbQZw8Dq2jMNG6je4JlWU0gWg== | ||
|
||
combined-stream@^1.0.6, combined-stream@~1.0.6: | ||
combined-stream@^1.0.6, combined-stream@^1.0.8, combined-stream@~1.0.6: | ||
version "1.0.8" | ||
resolved "https://registry.yarnpkg.com/combined-stream/-/combined-stream-1.0.8.tgz#c3d45a8b34fd730631a110a8a2520682b31d5a7f" | ||
integrity sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg== | ||
|
@@ -2734,6 +2752,11 @@ fast-safe-stringify@^2.0.6: | |
resolved "https://registry.yarnpkg.com/fast-safe-stringify/-/fast-safe-stringify-2.0.6.tgz#04b26106cc56681f51a044cfc0d76cf0008ac2c2" | ||
integrity sha512-q8BZ89jjc+mz08rSxROs8VsrBBcn1SIw1kq9NjolL509tkABRk9io01RAjSaEv1Xb2uFLt8VtRiZbGp5H8iDtg== | ||
|
||
fast-safe-stringify@^2.0.7: | ||
version "2.0.7" | ||
resolved "https://registry.yarnpkg.com/fast-safe-stringify/-/fast-safe-stringify-2.0.7.tgz#124aa885899261f68aedb42a7c080de9da608743" | ||
integrity sha512-Utm6CdzT+6xsDk2m8S6uL8VHxNwI6Jub+e9NYTcAms28T84pTa25GJQV9j0CY0N1rM8hK4x6grpF2BQf+2qwVA== | ||
|
||
fd-slicer@~1.0.1: | ||
version "1.0.1" | ||
resolved "https://registry.yarnpkg.com/fd-slicer/-/fd-slicer-1.0.1.tgz#8b5bcbd9ec327c5041bf9ab023fd6750f1177e65" | ||
|
@@ -2978,6 +3001,15 @@ form-data@^2.5.0: | |
combined-stream "^1.0.6" | ||
mime-types "^2.1.12" | ||
|
||
form-data@^3.0.0: | ||
version "3.0.0" | ||
resolved "https://registry.yarnpkg.com/form-data/-/form-data-3.0.0.tgz#31b7e39c85f1355b7139ee0c647cf0de7f83c682" | ||
integrity sha512-CKMFDglpbMi6PyN+brwB9Q/GOw0eAnsrEZDgcsH5Krhz5Od/haKHAX0NmQfha2zPPz0JpWzA7GJHGSnvCRLWsg== | ||
dependencies: | ||
asynckit "^0.4.0" | ||
combined-stream "^1.0.8" | ||
mime-types "^2.1.12" | ||
|
||
form-data@~2.3.2: | ||
version "2.3.3" | ||
resolved "https://registry.yarnpkg.com/form-data/-/form-data-2.3.3.tgz#dcce52c05f644f298c6a7ab936bd724ceffbf3a6" | ||
|
@@ -4299,7 +4331,7 @@ js-tokens@^3.0.2: | |
resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-3.0.2.tgz#9866df395102130e38f7f996bceb65443209c25b" | ||
integrity sha1-mGbfOVECEw449/mWvOtlRDIJwls= | ||
|
||
[email protected], [email protected], js-yaml@^3.13.1, js-yaml@^3.7.0, js-yaml@^3.9.1: | ||
[email protected], [email protected], js-yaml@^3.13.1, js-yaml@^3.7.0, js-yaml@^3.8.4, js-yaml@^3.9.1: | ||
version "3.13.1" | ||
resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.13.1.tgz#aff151b30bfdfa8e49e05da22e7415e9dfa37847" | ||
integrity sha512-YfbcO7jXDdyj0DGxYVSlSeQNHbD7XPWvrVWeVUujrQEoZzWJIRrCPoyk6kL6IAjAG2IolMK4T0hNUe0HOUs5Jw== | ||
|
@@ -7447,6 +7479,23 @@ stryker@^0.23.0: | |
tslib "^1.5.0" | ||
typed-rest-client "^1.0.7" | ||
|
||
superagent@5: | ||
version "5.2.2" | ||
resolved "https://registry.yarnpkg.com/superagent/-/superagent-5.2.2.tgz#6ff726c5642795b2c27009e92687c8e69a6bb07d" | ||
integrity sha512-pMWBUnIllK4ZTw7p/UaobiQPwAO5w/1NRRTDpV0FTVNmECztsxKspj3ZWEordVEaqpZtmOQJJna4yTLyC/q7PQ== | ||
dependencies: | ||
component-emitter "^1.3.0" | ||
cookiejar "^2.1.2" | ||
debug "^4.1.1" | ||
fast-safe-stringify "^2.0.7" | ||
form-data "^3.0.0" | ||
formidable "^1.2.1" | ||
methods "^1.1.2" | ||
mime "^2.4.4" | ||
qs "^6.9.1" | ||
readable-stream "^3.4.0" | ||
semver "^6.3.0" | ||
|
||
superagent@^3.7.0, superagent@^3.8.3: | ||
version "3.8.3" | ||
resolved "https://registry.yarnpkg.com/superagent/-/superagent-3.8.3.tgz#460ea0dbdb7d5b11bc4f78deba565f86a178e128" | ||
|