Skip to content

Commit

Permalink
feat(health): implement proper health check by pinging redis
Browse files Browse the repository at this point in the history
  • Loading branch information
NicolaiSchmid committed May 1, 2022
1 parent 4ca116b commit aa3a78c
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions lib/api-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,17 @@ class APIServer {
setupRoutes() {
this.server.get('/healthz', (req, res, next) => {
const redis = plugins.handler.options.db.redis;
console.log(redis);

res.json(200, {
redis: true
redis.ping((err, result) => {
console.log(err, result);
const status = err ? 500 : 200;

res.json(status, {
redis: err ? err : result
});

return next();
});
return next();
});

// Example handler for authentication. You should probably override it
Expand Down

0 comments on commit aa3a78c

Please sign in to comment.