Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add healthcheck #8

Merged
merged 1 commit into from
Apr 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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()