Restart Machines Automatically

Hi everyone,

I’m exploring ways to automatically restart my machines at regular intervals (like hourly or daily). I’ve come across the machine scheduling feature, but I’m not sure if it’s the right fit for this use case.

Ideally, I’d like the machine to restart itself without manual intervention. Is this possible with the machine scheduling feature?

If anyone has implemented automatic restarts using machine scheduling or any other approach, I’d love to hear how you did it!

Thanks in advance!

Hey, what is your exact use case? I’m guessing here but perhaps to restart your memory due to some memory leakage? You could exit your process with a non-zero status code after 1 hour, that should restart the server.

I run buggy app, that sometimes fails to connect to its API, I don’t have access to their source code. So the only way to maintain it in working state is to periodically forcedly restart it.

I’d start it as a sub-process if possible and just kill the process and return a non-zero exit code (like @khuezy suggested) which will force the machine to be restarted, so long as you have not defined your restart policy to be never. More on restart policies here.

You’ll probably want to verify that auto_start_machines is also set to true for your service if you’re operating an exposed HTTP service so that Fly proxy can start it up when a request comes in if the machine is shutdown and has not started. That shouldn’t happen with the right policy, but the feature exists, so I’d ensure you’re configured to use that feature.

1 Like

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