supervisor_bridge - Generic supervisor bridge behavior.
Contents
Callback Functions
The following functions must be exported from a supervisor_bridge callback module.
Description
This behavior module provides a supervisor bridge, a process that connects a subsystem not designed
according to the OTP design principles to a supervision tree. The supervisor bridge sits between a
supervisor and the subsystem. It behaves like a real supervisor to its own supervisor, but has a
different interface than a real supervisor to the subsystem. For more information, see Supervisor
Behaviour in OTP Design Principles.
A supervisor bridge assumes the functions for starting and stopping the subsystem to be located in a
callback module exporting a predefined set of functions.
The sys(3erl) module can be used for debugging a supervisor bridge.
Unless otherwise stated, all functions in this module fail if the specified supervisor bridge does not
exist or if bad arguments are specified.
Exports
Module:init(Args)->Result
Types:
Args = term()
Result = {ok,Pid,State} | ignore | {error,Error}
Pid = pid()
State = term()
Error = term()
Whenever a supervisor bridge is started using start_link/2,3, this function is called by the new
process to start the subsystem and initialize.
Args is the Args argument provided to the start function.
The function is to return {ok,Pid,State}, where Pid is the pid of the main process in the
subsystem and State is any term.
If later Pid terminates with a reason Reason, the supervisor bridge terminates with reason Reason
as well. If later the supervisor bridge is stopped by its supervisor with reason Reason, it calls
Module:terminate(Reason,State) to terminate.
If the initialization fails, the function is to return {error,Error}, where Error is any term, or
ignore.
Module:terminate(Reason,State)
Types:
Reason = shutdown | term()
State = term()
This function is called by the supervisor bridge when it is about to terminate. It is to be the
opposite of Module:init/1 and stop the subsystem and do any necessary cleaning up. The return
value is ignored.
Reason is shutdown if the supervisor bridge is terminated by its supervisor. If the supervisor
bridge terminates because a a linked process (apart from the main process of the subsystem) has
terminated with reason Term, then Reason becomes Term.
State is taken from the return value of Module:init/1.
Name
supervisor_bridge - Generic supervisor bridge behavior.
See Also
supervisor(3erl), sys(3erl) Ericsson AB stdlib 3.17 supervisor_bridge(3erl)
