diff --git a/Dockerfile b/Dockerfile index 7425701..a2dff6c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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 diff --git a/main.tf b/main.tf index 61dcee5..1966229 100644 --- a/main.tf +++ b/main.tf @@ -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" @@ -23,7 +22,7 @@ module "mobius3" { user = var.user command = [ - "mobius3", + "zmobius3", "/srv/data", var.bucket_id, "https://{}.s3.${var.bucket_region}.amazonaws.com/", @@ -33,13 +32,21 @@ 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 } @@ -47,7 +54,6 @@ module "mobius3" { locals { output_container_depends_on = { containerName = module.mobius3.json_map_object["name"] - # TODO: Use HEALTHY once we have a healthcheck - condition = "START" + condition = "HEALTHY" } } diff --git a/zmobius3.py b/zmobius3.py new file mode 100755 index 0000000..8b047ba --- /dev/null +++ b/zmobius3.py @@ -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() + +