Application stop() callback does not run when quitting phx.server

I would like to do some cleanup after phoenix quits (in development mode)

Thought something like this would work in application.ex but it does not

  def stop(state) do
    IO.puts("App stopped")
    Logger.debug(state)
  end

Please note that I run it locally in devmode via mix phx.server and is stopped using ctrl-c

I can solve it by using

iex -S mix phx.server for starting

:init.stop

And now the stop() func is run :slight_smile:

This does not issue a clean shutdown, so it’s expected for Application.stop/1 to not be ensured to run.

2 Likes

Try using ctrl-g q

2 Likes