[erlang-questions] Restore state on supervisor restart

Ulf Wiger <>
Wed Mar 18 17:19:29 CET 2009

The supervisor will always start the child with the same arguments, for better or for worse. A common trick is to create an ets table in the supervisor (e.g. in the supervisor init() callback, or in the child start function before spawning the process, taking care not to try to create it more than once.) This way, your server can store data in the ets table that  survives a process crash (but not an escalate restart.) Using a mnesia ram_copy table is also possible.

Ulf W

-- originalmedd. --
Ämne: [erlang-questions] Restore state on supervisor restart
Från: Dave Bryson <>
Datum: 2009.03.18 15.48

I have a gen_server that's linked to a supervisor. When the gen_server  
is started it uses some arguments passed on the command line to erl to  
setup its state.  If the gen_server dies, I want the supervisor to use  
the gen_server's last state to restart it.  How can I pass the last  
state of the dying gen_server to the supervisor for restart? Is this  
possible without persisting the state to disk?

erlang-questions mailing list


More information about the erlang-questions mailing list