Scheduled machine constantly restarting

I have some jobs that only need to be run periodically and to reduce costs & scale down to zero I want to run a scheduled machine hourly. I have an app already that has 2 instances that auto-start and auto-stop, down to a minimum of 0 instances, and I am attempting to add an additional machine that will run the on the schedule:

fly machines run . --schedule=hourly --region syd -a <my-app>

However, when I do this, I can see the machine start, run the job for the first time but after it exits it immediately starts again. I initially thought it might be because I wasn’t returning a 0 exit code, but even when I do this the same behaviour is continuing.

I can see in the logs that the my job completes successfully, but there some logging after this point that leads me to believe something isn’t entirely right:

2023-06-01T08:29:05.408 app[9080eed0b1de48] syd [info] Starting clean up.
2023-06-01T08:29:05.409 app[9080eed0b1de48] syd [info] hallpass exited, pid: 514, status: signal: 15

Signal 15 being a SIGTERM I believe.

Am I doing something wrong here or is this an issue with Fly? Thanks in advance!

Hi @juliancarrivick

That’s hallpass (SSH server) being terminated. So unrelated to the problem.

It looks like machine run sets restart policy to always if not specified. Can you try like this, please?

$ fly machines run . --schedule=hourly --restart on-fail --region syd -a <my-app>

Oh brilliant! That’s done the job, thanks! :raised_hands:

Looks like I’ll have to manually update the machine when deploying new versions of my app, but that’s not a biggie.

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