Elixir release stops previously started server

I tried to deploy something using this guide. I have now a working server, deployed using elixir releases and managed with traefik, but there is one problem.

The guide works like this: if a server is already running on port 4000, start a new one on port 4001, wait till it is up, stop the old one and be done. Sadly this does not work as described in the guide. If the script detects the one on 4001 is healthy and returning 200 for the curl, it tries to stop the old process, but by stopping the old process, it is also killing the new started one.

Systemd detects this and restarts the 4001 one, but this means for a short period there is no running server and this dance with starting a new one and then stopping the old one is not working as expected :sob: .

Is there a workaround for this? Or a better guide that has another approach, but is still working with releases and one server (without cloud stuff).