Old instance does not shut down after deploying code

Apologies if this is a dumb question as I’ve just started using Fly today. I had assumed that when I deploy new code, it would kill the old instance automatically. Instead, the old instance continues running alongside the new instance that is started up after I deploy new code. Should I just be killing the old instance myself first before deploying? If so, what command do I run to kill the old/current instance? I’ve just been deploying and then running flyctl apps restart [my_app]

Could be a Fly control plane issue:

Hmm, in my case it feels like everything is working as intended, maybe fly just isn’t set up to automatically kill the old instance when I deploy code? I can see both instances in my dashboard and by running flyctl status.

I just find it a little inconvenient that I have to deploy and then restart the app to kill both instances and start a new one so I only have one instance running. I feel like I must be missing something here, but I can’t find a command to kill the old instance with flyctl. I guess I may just have to modify my code and create a command to kill it myself instead of using flyctl to do it.

Pretty sure Fly’s control plane is supposed to rid of VMs running older deploy versions. May be a bug on their end. What deployment strategy (ex: rolling, rolling_one, canary, bluegreen, immediate) are you using? Once upon a time, some folks had issues with bluegreen in particular; and others with using release_command + rolling deploys; but haven’t seen those reported lately.

I haven’t had to try this myself, but does fly vm stop <vm-id> -a <app-name> work (ref: other vm cmds)?

I didn’t have a deployment strategy set in my TOML file (I just started today and was using the one that was generated), so I assume it was probably canary by default according to the documentation I am looking at. I tried setting it to canary before deploying again, but I am getting the same results.

flyctl vm stop <vm-id> does kill the vm instance, but then that instance just restarts itself immediately afterwards for some reason…

By the way, thanks for linking the other vm commands, I’ve now realized that there were more commands that I could’ve seen if I had just run flyctl help commands.

1 Like

Update: I changed my deployment strategy to rolling in the TOML file, and it now kills the first instance and then spins up the new one as I wanted. Thanks for all the help and the quick responses @ignoramous :sweat_smile:

1 Like