I have an application, which uses Application
module, and also has an GenServer
instance running. This GenServer
module has a terminate
callback.
The callback works fine if I force some error happen inside server instance, but doesn't fire if I abort the iex -S mix
session using Ctrl-C a
or by just closing console window (it should write into some file).
I've tried putting this in init()
:
Process.flag(:trap_exit, true)
and also calling stop/1
in the main module:
def stop(state) do
IO.puts "something" #never shown
GenServer.stop(pid) #doesn't seem to work
end