Issues with machines restart policy

How do I set this in the fly.toml?

I just created a app and it defaulted to empty.

Did you create a new v2 app or just a machine?

A new app, sorry.

The Machine restart policy isn’t yet a part of app-wide configuration. It will get there.

In the meantime, you don’t have to go all the way to the API: flyctl can do it with fly machine update. Unfortunately, yes, once you’ve scaled up, that currently means you have to run it on each Machine separately.

1 Like

What command do I need to run exactly?

fly machines update <machine-id>

Yes I know that, but to change the restart policy specifically, when I run this it tells me there is no change to the config.

If you’re certain your machine doesn’t have that policy then no idea. That’s what worked for me.

To check the JSON config you can do:

fly m status <machine-id> -d

With this my restart section is this:

 "restart": {},

@pacsni It sounds like you’re still having the issue you reported in, e.g. , Guide: Elixir App v1 to v2 migration (It was easy) - #16 by pacsni?

i.e. you’re trying fly machine update with definite config changes, and getting back Error no config changes found instead of a diff and a request to confirm?

Can you confirm that with the latest stable flyctl, running fly m update --restart always <machine-id> doesn’t work?

1 Like

Hey,

I am on 0.0.504 .
When I run this command I see:

flyctl machine update --restart always 91857d7f2d6983 -a APPNAME
Searching for image 'registry.fly.io/APPNAME:deployment-01GX2NH37D1554RQN3P4BWVXEJ@sha256:7c86850b8bb252ca95e4a20f7fa9af541f3fba351e662c9e4926216f50537747' remotely...
image found: img_dozgpek1e6mp096y
Image: registry.fly.io/APPNAME:deployment-01GX2NH37D1554RQN3P4BWVXEJ
Image size: 151 MB

Error no config changes found

For that other report, the scale command worked.

2 Likes

Thank you.

1 Like

What are the different restart policies? I couldn’t find the appropriate documentation.

2 Likes

There are three policies (using the names of the options in fly m update and fly m run help):

no - always let a Machine stop when its main process exits, whether that’s on purpose or on a crash

always - never let a Machine enter the stopped state, even if your main process exits cleanly

on-fail - try up to 10 times to restart the Machine if it exits with a non-zero exit code, before letting it stop. This is the default behaviour if the policy is not specified.

Right now, the default on fly machine run is always. Fly Postgres apps are configured with a policy of always, too.

The default for a new Fly App (V2 of course, since V1 doesn’t use Machines) is an empty policy, equivalent to on-fail. This lets Machines be restarted if they crash, and allows your app Machines to effectively scale down by exiting cleanly, but:

At the moment:

If Fly Proxy can wake it on request (regular web app Machine with services configured), or you do active scaling via the API, the default on-fail policy should be good.

For an always-on app with no services: host reboots could stop Machines. If you want to set and forget, always is the best policy.

Right now, fly machine update (or the Machines API) is the way to change the policy. It doesn’t exist in app-wide configuration yet, so fly.toml won’t help.

5 Likes

Is there a way to disable wake on request?

Sorry for the confusion it will cause but I edited the title of this thread.

1 Like

I believe the answer to this one is “not yet but soon.” As far as I’m aware, today, if your Machines have services defined, Fly Proxy will wake them up when it happens to hit them in its load-balancing efforts.

3 Likes

Would you know if removing machines out of the pool on the roadmap somewhere?

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.