Alternative to killall for stopping an Elixir process

Hey all,

I’ve been a happily rolling out my deployments using a script that starts with:
killall beam.smp || true … up until now.

Now, I am downscaling by running multiple phoenix servers on a single droplet, but that renders the previous hack moot. I’ve tried to use $! to get the pid, but I guess I’m doing something wrong since it always returns 0.

I found that running :os.getpid returns the OS pid within Elixir, but what would be the best practice to writing that to a file somewhere, in order to stop the server later on?

The command I use to run a server is:

elixir --detached --sname logging -S mix do deps.get, compile, phoenix.server

The best practice would be using releases, and using the scripts they provide to start and stop your server gracefully instead of using killall.

4 Likes

I guess I’ve been putting that off for too long now … Will switch to releases, thanks.