However, I’m getting 2 machines in the SCL region instead of MIA, and my project is scaling to zero. So it always is suspended and with both machines stopped, unless I make a request to the server and one of the machine gets temporarily activated for a short time, then goes back into suspension.
Assuming that there isn’t an issue on Fly.io, did you accidentally create your app in scl and then updated your config to mia? If so, fly deploy doesn’t look at the region, it only configures that at launch (initial) time. fly scale count 0 to clear them, then go back up to 2. min_machines_running only applies to the original primary region.
I used fly launch for creating the project with the fly.toml already created and configured like I showed. I tried fly scale count 0 and setting it back to 2 but that didn’t work. I’m still getting the new machines on SCL, even though my config is still in MIA.
I’m wondering if your new app is actually using the fly.toml above or if the launch scanner is detecting your app and creating a new fly.toml file with the primary region set to your closest region?
When you ran fly launch did you note the region that was output in the suggested settings for the app?
You can also specify the region when you run that scale command using the --region mia option. Just note if you still have machines in the scl region, you’ll want to specify that region when you scale it to 0.
That would fix the region issue manually, but I want to make fly respect the fly.toml file I have, since the region is only one of the issues (I want also to respect the other configs in fly.toml, like min_machines_running=1)
You need to make sure the fly.toml file with the settings you want is at the top level of your project directory where you run your commands.
If you then scale to zero (fly scale count 0)and then redeploy with fly deploy, the deploy (and any subsequent deploys) should respect the fly.toml settings.
Did that with fly.toml at the root of my project and still, no luck. Still deploying at a different region and probably not respecting any other configs inside my fly.toml
I took at a peek at your fly.toml from our side and it’s not the same file you posted above. It looks like a default file, with default settings, and the region set to “scl”.
I’m not sure why!
Could you try making a copy of your project and just running fly launch in it? You can say y to tweak settings and change the region to mia before deploy. Once it’s deployed, open the new fly.toml file and edit min_machines_running to 1, save it, then run fly deploy. This should result in the app behaviour and settings you want.
I’m going to do some testing of what happens when you use fly launch with an existing fly.toml and see if we can improve things at all. It should be an acceptable workflow and it might not be clear enough what’s happening. Glad your app is working as it should now!