How to honour restart attempt limit?

What is the point of the restart count configuration ()?

I’m seeing the following logs on an instance:

2024-11-24T14:44:28Z runner[] cdg [info]machine has reached its max restart count of 10
2024-11-24T14:44:33Z proxy[] cdg [info]waiting for machine to be reachable on 0.0.0.0:8080 (waited 12.53250087s so far)
2024-11-24T14:44:35Z proxy[] cdg [error][PM05] failed to connect to machine: gave up after 15 attempts (in 14.533430503s)
2024-11-24T14:44:37Z proxy[] cdg [info]Starting machine
etc.

So basically, the machine hits its max restart count, and then… immediately restarts.

Is there a way to make it stop trying to restart?

1 Like

There’s nothing to stop the proxy from starting a machine from a stopped state when a request comes in. The restart policy is used to decide what to do when a machine exits with a non-zero exit code.

Thanks, this probably explains why the machine was restarting. But do you mean this literally? It would actually be helpful in some circumstances to configure a stopped machine to NOT restart when a new request comes in.

Can you show examples of that use case?

ok, here’s an example in nodeJS:

// on startup
await expensive3rdPartyApiCall();
throw new Error('something unrelated went wrong');

Can you explain more?

The best ways to do that right now is create a lease for the machine for however long you need it to stay stopped. The proxy is unable to start a machine with an active lease. fly machine leases · Fly Docs.

The other is to cordon the machine, fly machine cordon · Fly Docs and you can uncordon it when you’re ready for it to start back.

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