File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ WORKDIR /rails
1010
1111# Install base packages
1212RUN apt-get update -qq && \
13- apt-get install --no-install-recommends -y curl libjemalloc2 libvips libicu-dev postgresql-client && \
13+ apt-get install --no-install-recommends -y curl libjemalloc2 libvips libicu-dev postgresql-client jq && \
1414 rm -rf /var/lib/apt/lists /var/cache/apt/archives
1515
1616# Set production environment
Original file line number Diff line number Diff line change 1+ #! /usr/bin/env bash
2+
3+ export PGPASSWORD=" $( echo $DB_CREDENTIALS | jq -r .password) "
4+ psql -h " $DB_HOST " -d " $DB_NAME " -U " $( echo $DB_CREDENTIALS | jq -r .username) " -c " select 1" || {
5+ echo " DB connection could not be established: Internal healthcheck failed." ; exit 1;
6+ }
7+ curl -f " $1 " || {
8+ echo " DB connection could not be established, but $1 did not return a 200 response." ; exit 2;
9+ }
Original file line number Diff line number Diff line change @@ -31,7 +31,7 @@ module "web_service" {
3131 task_role_arn = aws_iam_role.ecs_task_role.arn
3232 log_group_name = aws_cloudwatch_log_group.ecs_log_group.name
3333 region = var.region
34- health_check_command = [" CMD-SHELL" , " curl -f http://localhost:4000/health/database || exit 1 " ]
34+ health_check_command = [" CMD-SHELL" , " ./bin/internal_healthcheck http://localhost:4000/health/database" ]
3535 }
3636 network_params = {
3737 subnets = [aws_subnet.private_subnet_a.id, aws_subnet.private_subnet_b.id]
@@ -70,7 +70,7 @@ module "good_job_service" {
7070 task_role_arn = aws_iam_role.ecs_task_role.arn
7171 log_group_name = aws_cloudwatch_log_group.ecs_log_group.name
7272 region = var.region
73- health_check_command = [" CMD-SHELL" , " curl -f http://localhost:4000/status/connected || exit 1 " ]
73+ health_check_command = [" CMD-SHELL" , " ./bin/internal_healthcheck http://localhost:4000/status/connected" ]
7474 }
7575 network_params = {
7676 subnets = [aws_subnet.private_subnet_a.id, aws_subnet.private_subnet_b.id]
Original file line number Diff line number Diff line change @@ -82,8 +82,8 @@ resource "aws_lb_target_group" "blue" {
8282 protocol = " HTTP"
8383 port = " traffic-port"
8484 matcher = " 200"
85- interval = 10
86- timeout = 5
85+ interval = 5
86+ timeout = 4
8787 healthy_threshold = 2
8888 unhealthy_threshold = 2
8989 }
@@ -100,8 +100,8 @@ resource "aws_lb_target_group" "green" {
100100 protocol = " HTTP"
101101 port = " traffic-port"
102102 matcher = " 200"
103- interval = 10
104- timeout = 5
103+ interval = 5
104+ timeout = 4
105105 healthy_threshold = 2
106106 unhealthy_threshold = 2
107107 }
You can’t perform that action at this time.
0 commit comments