最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

How to debug why a check is not being applied to a Fly.io machine clone? - Stack Overflow

programmeradmin3浏览0评论

I am playing around with Fly.io. I want to do my own orchestration, so I'm spinning up containers as machines rather than as apps. They do not need to have high availability as they will be short-lived; they will do some work and then self-destroy.

I would like to enable the platform health-checks. This is more for completeness rather than switching internet traffic away (the machines will only be contacted individually via IPv6 on the internal network anyway).

Here is my simple Dockerfile, which starts up a web server (in sleep.sh) and then waits for a few minutes before exiting:

FROM php:8.3-alpine

WORKDIR /root
COPY docker/sleep.sh /root/sleep.sh
COPY healthcheck /project/healthcheck

CMD ["sh", "/root/sleep.sh"]

The web server is for the health-check, and the sleep emulates the workload before exit.

Here is my Fly config:

app = 'sequoia-browser-test'
primary_region = 'lhr'

[build]

[http_service]
  internal_port = 8080
  force_https = true
  auto_stop_machines = 'stop'
  auto_start_machines = true
  min_machines_running = 0

[checks]
  [checks.machine_health]
    type = "http"
    grace_period = "5s"
    interval = "10s"
    timeout = "2s"
    port = 80
    method = "get"
    path = "/health.html"

[[restart]]
  policy = 'never'

[[vm]]
  cpu_kind = 'shared'
  cpus = 1
  memory_mb = 256

Here is how I create a non-running "template" for my machine:

#!/bin/bash

flyctl machine create \
    . \
    --dockerfile Dockerfile.dummy \
    --rm \
    --region lhr \
    --name sequoia-browser-small

And then finally I start one up via cloning the created machine:

#!/bin/bash

MACHINE_ID=$(flyctl machine list | grep sequoia-browser-small | cut -f 1)
echo "Source machine is $MACHINE_ID"

flyctl machine clone $MACHINE_ID

This works in the sense that the machine starts, sleeps for a bit, exits, and destroys itself. Here is a clone log:

Source machine is 4d89033d000000
Cloning Machine 4d89033d000000 into region lhr
Auto destroy enabled and will destroy Machine on exit. Use --clear-auto-destroy to remove this setting.
Provisioning a new Machine with image registry.fly.io/sequoia-browser-test:deployment-01XM6XSC8X6R8XTX87SE7FXS9X...
  Machine 6e825664000000 has been created...
  Waiting for Machine 6e825664000000 to start...
No health checks found
Machine has been successfully cloned!

As can be seen above, it does not know of any healthchecks, and that can be further shown here:

flyctl checks list
Health Checks for sequoia-browser-test
  NAME | STATUS | MACHINE | LAST UPDATED | OUTPUT  
-------*--------*---------*--------------*---------

Do these only work at the app level? If so, how can I enable machine level checks?

Update

I also tried adding a HEALTHCHECK CMD curl --fail http://localhost/health.html || exit 1 to the Dockerfile, but it made no odds.

发布评论

评论列表(0)

  1. 暂无评论