From ae164d7bf16aacb0f0a2a1e4045d2001507274f0 Mon Sep 17 00:00:00 2001 From: George Whitaker Date: Fri, 28 Apr 2017 07:25:03 -0400 Subject: [PATCH 1/2] add health check --- lib/bot.coffee | 2 ++ lib/health_check_receiver.coffee | 10 ++++++++++ 2 files changed, 12 insertions(+) create mode 100644 lib/health_check_receiver.coffee diff --git a/lib/bot.coffee b/lib/bot.coffee index 1a3fdc84..64ba8e8d 100644 --- a/lib/bot.coffee +++ b/lib/bot.coffee @@ -21,6 +21,7 @@ LookQueryRunner = require('./repliers/look_query_runner') versionChecker = require('./version_checker') ScheduleReceiver = require('./schedule_receiver') DataActionReceiver = require('./data_action_receiver') +HealthCheckReceiver = require('./health_check_receiver') if process.env.DEV == "true" # Allow communicating with Lookers running on localhost with self-signed certificates @@ -206,6 +207,7 @@ controller.setupWebserver process.env.PORT || 3333, (err, expressWebserver) -> controller.createWebhookEndpoints(expressWebserver) ScheduleReceiver.listen(expressWebserver, defaultBot, lookers) DataActionReceiver.listen(expressWebserver, defaultBot, lookers) + HealthCheckReceiver.listen(expressWebserver, defaultBot, lookers) controller.on 'rtm_reconnect_failed', -> throw new Error("Failed to reconnect to the Slack RTM API.") diff --git a/lib/health_check_receiver.coffee b/lib/health_check_receiver.coffee new file mode 100644 index 00000000..fbba94cc --- /dev/null +++ b/lib/health_check_receiver.coffee @@ -0,0 +1,10 @@ +module.exports = + + listen: (server, bot, lookers) -> + server.get("/health_check", (req, res) => + + reply = (json) -> + res.setHeader 'Content-Type', 'application/json' + res.send JSON.stringify(json) + reply {success: true, reason: "Healthy"} + ) \ No newline at end of file From f9cd486f67121b4cfceb6a2b0a074d9c54dc5927 Mon Sep 17 00:00:00 2001 From: George Whitaker Date: Fri, 28 Apr 2017 07:38:42 -0400 Subject: [PATCH 2/2] bump version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 26393928..d8f56448 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "looker-slackbot", - "version": "0.0.9", + "version": "0.0.10", "description": "Slackbot for Looker integration", "main": "index.js", "scripts": {