I would like to deploy a background worker without any http_service. There should be exactly one instance of the worker, and it should not be publicly accessible.
My question is: what should the fly.toml look like?
I have a Dockerfile ready to deploy. The program just loops, and jobs are fired off interally based on a cron expression. All it does is make external API calls and save some data to a database.
So far, it seems to be working. After deploying, fly creates a single machine with the Dockerfile running and it seems to be staying alive. How can I ensure that there is exactly one of these running at all times? It should never be scaled down to 0, and never scaled up beyond 1.
Since the auto stop and stop feature only applies to Machines with services, you shouldn’t see any automatic scaling happening with this setup.
I’d suggest setting the Machine restart policy to always so that your Machine restarts if the host ever reboots. You can read more about restart policies here, but the important bit in your case is: