How do I change the restart policy for Machines?

I think this is similar to this Machine did not have a restart policy, defaulting to restart, which did not offer a solution that worked for me.

If one of my machines fail I don’t want it to restart. I’m not seeing where I can set the restart policy. Attempting to add it to the configuration leads to a server time out.

When you spawn your machine you can add this to your config:

  ...other configs for your machine...
  "restart": {
    "policy": "no",

Available options to policy are “no”, “always” and “on-failure”

Don’t forget that if you’re updating a machine you need to provide the full config too :slight_smile:


Ah okay, I tried setting it to false. Thanks!

1 Like

Neat! Is this possible with machines deployed using the flyctl deploy -c fly.toml cmd? If so, which section of the toml should this policy be defined?

1 Like

Regular fly deploy doesn’t use machine yet. Right now regular apps restart when your checks don’t pass: App Configuration (fly.toml) · Fly Docs

flyctl deploy -c ... does support Machines (but with caveats): Preview: Deploying applications on Machines with flyctl I’ve used it, and it works (for the most part).

I’d expect Machines to also restart on health-check failures (or restart on any non-zero exit code)?

Yea, it’s currently on preview right now :slight_smile:

Health checks for machines is something we are still working on :slight_smile:

1 Like

Most our services rely on health checks. Any timeline for these for Machines?

  1. If there aren’t health-checks for Machines, what does the restart-policy act on? Does it monitor the exit code to apply restart-policies?
    a. Does no mean, a new vm is started on next request?
    b. Does always mean, even if it exits with 0, the main process is restarted inside the existing vm?
    c. Does on-failure mean, only on non-zero exit codes, the main process is restarted in the existing vm?
  2. What does the default policy do? In all our Machine configs, the restart-policy is empty.
      "restart": {                                                              
        "policy": ""