Skip to content

Commit

Permalink
feat: add healthcheck for both client and server
Browse files Browse the repository at this point in the history
The broker is considered healthy if it was successfully able to start.
  • Loading branch information
gjvis committed Sep 2, 2016
1 parent af398c9 commit e21ddc3
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
9 changes: 9 additions & 0 deletions lib/healthcheck.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
const express = require('express');
const router = express.Router();

module.exports = router;

router.route('/').get(function (req, res, next) {
// Only check currently is that the webserver is up
res.status(200).json({ ok: true });
});
1 change: 1 addition & 0 deletions lib/webserver.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ function main({ key = null, cert = null, port = 7341 } = {}, altPort = null) {

app.disable('x-powered-by');
app.use(bodyParser.json());
app.use('/healthcheck', require('./healthcheck'));

if (altPort) {
port = altPort;
Expand Down
2 changes: 0 additions & 2 deletions test/functional/healthcheck.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@ test('client healthcheck', t => {
process.env.SECRET = 'secret';
process.env.PORT = localPort;
process.env.ACCEPT = 'filters.json';
// process.env.BROKER_URL = `http://localhost:${serverPort}`;
// process.env.BROKER_ID = '12345';
process.env.BROKER_TYPE = 'client';
const client = app.main({ port: port() });

Expand Down

0 comments on commit e21ddc3

Please sign in to comment.