Skip to content

Commit

Permalink
Merge pull request #8 from zeroae/chore/live-probe
Browse files Browse the repository at this point in the history
Add healthcheck
  • Loading branch information
sodre authored Apr 15, 2022
2 parents 9734b27 + 36055e6 commit a4a0c47
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 11 deletions.
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ RUN addgroup -S mobius3 && \
WORKDIR /home/mobius3

RUN pip install mobius3==0.0.34
COPY zmobius3.py /usr/bin/zmobius3

USER mobius3

28 changes: 17 additions & 11 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ module "volume_label" {
label_order = ["name"]
}

# TODO: Implement a health check
# TODO: Support different user/groups
module "mobius3" {
source = "git::https://github.com/cloudposse/terraform-aws-ecs-container-definition.git?ref=tags/0.57.0"
Expand All @@ -23,7 +22,7 @@ module "mobius3" {
user = var.user

command = [
"mobius3",
"zmobius3",
"/srv/data",
var.bucket_id,
"https://{}.s3.${var.bucket_region}.amazonaws.com/",
Expand All @@ -33,21 +32,28 @@ module "mobius3" {
"--log-level", "INFO"
]

mount_points = [
{
containerPath = "/srv/data"
sourceVolume = module.volume_label.id
readOnly = false
}
]
healthcheck = {
command = ["/bin/sh", "-c",
"cat /tmp/ruok | grep imok"
]
retries = 3
timeout = 3
interval = 10
startPeriod = 60
}

mount_points = [{
containerPath = "/srv/data"
sourceVolume = module.volume_label.id
readOnly = false
}]

log_configuration = var.log_configuration
}

locals {
output_container_depends_on = {
containerName = module.mobius3.json_map_object["name"]
# TODO: Use HEALTHY once we have a healthcheck
condition = "START"
condition = "HEALTHY"
}
}
19 changes: 19 additions & 0 deletions zmobius3.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/env python
import mobius3


super_async_main = mobius3.async_main


async def async_main(syncer_args):
stop = await super_async_main(syncer_args)
with open("/tmp/ruok", "w") as f:
f.write("imok")
return stop


if __name__ == "__main__":
mobius3.async_main = async_main
mobius3.main()


0 comments on commit a4a0c47

Please sign in to comment.