Skip to content
Permalink
Browse files

add healthcheck endpoint

  • Loading branch information...
shmish111 committed Jun 12, 2019
1 parent cc9f280 commit c88affad27f2c1c17d437808f5ce401389fd7e50
Showing with 13 additions and 2 deletions.
  1. +6 −2 deployment-server/src/Deploy/Server.hs
  2. +7 −0 deployment/terraform/loadbalancing.tf
@@ -14,12 +14,13 @@ import GitHub.Data.Webhooks.Events (PullRequestEvent (evPullReqPayloa
import GitHub.Data.Webhooks.Payload (HookPullRequest (whPullReqMergedAt))
import Network.Wai (Application)
import Servant (Context ((:.), EmptyContext), Handler, serveWithContext)
import Servant.API ((:>), JSON, Post)
import Servant.API ((:>), (:<|>)((:<|>)), JSON, Post, Get)
import Servant.GitHub.Webhook (GitHubEvent, GitHubKey, GitHubSignedReqBody,
RepoWebhookEvent (WebhookPullRequestEvent))

type Api
= "github" :> GitHubEvent '[ 'WebhookPullRequestEvent] :> GitHubSignedReqBody '[ JSON] PullRequestEvent :> Post '[ JSON] ()
:<|> "health" :> Get '[JSON] ()

isMergePullRequestEvent :: PullRequestEvent -> Bool
isMergePullRequestEvent = isJust . whPullReqMergedAt . evPullReqPayload
@@ -29,6 +30,9 @@ prEventAction chan _ (_, event)
| isMergePullRequestEvent event = liftIO $ writeChan chan event
prEventAction _ _ _ = liftIO $ putStrLn "non-merge PullRequestEvent"

healthCheck :: Handler ()
healthCheck = pure ()

app :: Chan PullRequestEvent -> GitHubKey PullRequestEvent -> Application
app chan key =
serveWithContext (Proxy :: Proxy Api) (key :. EmptyContext) $ prEventAction chan
serveWithContext (Proxy :: Proxy Api) (key :. EmptyContext) $ prEventAction chan :<|> healthCheck
@@ -41,6 +41,13 @@ resource "aws_security_group" "public_alb" {
cidr_blocks = ["${var.private_subnet_cidrs}"]
}

egress {
from_port = "4000"
to_port = "4000"
protocol = "TCP"
cidr_blocks = ["${var.private_subnet_cidrs}"]
}

tags {
Name = "${var.project}_${var.env}_public_alb"
Project = "${var.project}"

0 comments on commit c88affa

Please sign in to comment.
You can’t perform that action at this time.