/doc/core/z_supervisor.html

http://github.com/zotonic/zotonic · HTML · 135 lines · 113 code · 22 blank · 0 comment · 0 complexity · 9d45aae29c8490928f8707090f08b01f MD5 · raw file

  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  2. <html>
  3. <head>
  4. <title>Module z_supervisor</title>
  5. <link rel="stylesheet" type="text/css" href="stylesheet.css" title="EDoc">
  6. </head>
  7. <body bgcolor="white">
  8. <div class="navbar"><a name="#navbar_top"></a><table width="100%" border="0" cellspacing="0" cellpadding="2" summary="navigation bar"><tr><td><a href="overview-summary.html" target="overviewFrame">Overview</a></td><td><a href="http://www.erlang.org/"><img src="erlang.png" align="right" border="0" alt="erlang logo"></a></td></tr></table></div>
  9. <hr>
  10. <h1>Module z_supervisor</h1>
  11. <ul class="index"><li><a href="#description">Description</a></li><li><a href="#index">Function Index</a></li><li><a href="#functions">Function Details</a></li></ul>Supervisor with a one_for_one strategy and disabling of too-often-crashing resources.
  12. <p>Copyright Š 2010 Marc Worrell</p>
  13. <p><b>Behaviours:</b> <a href="gen_server.html"><tt>gen_server</tt></a>.</p>
  14. <p><b>Authors:</b> Marc Worrell (<a href="mailto:marc@worrell.nl"><tt>marc@worrell.nl</tt></a>).</p>
  15. <h2><a name="description">Description</a></h2>Supervisor with a one_for_one strategy and disabling of too-often-crashing resources.
  16. All children of this supervisor should be gen_server/supervisor processes.
  17. <h2><a name="index">Function Index</a></h2>
  18. <table width="100%" border="1" cellspacing="0" cellpadding="2" summary="function index"><tr><td valign="top"><a href="#add_child-2">add_child/2</a></td><td>Add a child, the child will be added and started.</td></tr>
  19. <tr><td valign="top"><a href="#check_children-1">check_children/1</a></td><td>Check children, try restarting children when they are in 'error' state.</td></tr>
  20. <tr><td valign="top"><a href="#code_change-3">code_change/3</a></td><td>Convert process state when code is changed.</td></tr>
  21. <tr><td valign="top"><a href="#delete_child-2">delete_child/2</a></td><td>Delete a child, the child will be terminated and removed.</td></tr>
  22. <tr><td valign="top"><a href="#handle_call-3">handle_call/3</a></td><td>Add a child in the stopped state.</td></tr>
  23. <tr><td valign="top"><a href="#handle_cast-2">handle_cast/2</a></td><td>Stop a child process and add it to the stopped list.</td></tr>
  24. <tr><td valign="top"><a href="#handle_info-2">handle_info/2</a></td><td>Handle the exit of a child.</td></tr>
  25. <tr><td valign="top"><a href="#init-1">init/1</a></td><td>Initiates the server.</td></tr>
  26. <tr><td valign="top"><a href="#restart_child-2">restart_child/2</a></td><td>Terminate and restart a child.</td></tr>
  27. <tr><td valign="top"><a href="#running_children-1">running_children/1</a></td><td>Return the list of running children.</td></tr>
  28. <tr><td valign="top"><a href="#set_manager_pid-2">set_manager_pid/2</a></td><td>Set the manager pid for this supervisor.</td></tr>
  29. <tr><td valign="top"><a href="#start_child-2">start_child/2</a></td><td>Start a child when it is not running (either failed or stopped).</td></tr>
  30. <tr><td valign="top"><a href="#start_link-1">start_link/1</a></td><td></td></tr>
  31. <tr><td valign="top"><a href="#start_link-2">start_link/2</a></td><td></td></tr>
  32. <tr><td valign="top"><a href="#stop_child-2">stop_child/2</a></td><td>Stop a child, the child will be terminated and put in "stopped" state.</td></tr>
  33. <tr><td valign="top"><a href="#terminate-2">terminate/2</a></td><td>This function is called by a gen_server when it is about to
  34. terminate.</td></tr>
  35. <tr><td valign="top"><a href="#which_children-1">which_children/1</a></td><td>Return the list of all children and their run state.</td></tr>
  36. </table>
  37. <h2><a name="functions">Function Details</a></h2>
  38. <h3 class="function"><a name="add_child-2">add_child/2</a></h3>
  39. <div class="spec">
  40. <p><tt>add_child(Pid, ChildSpec) -&gt; any()</tt></p>
  41. </div><p>Add a child, the child will be added and started.</p>
  42. <h3 class="function"><a name="check_children-1">check_children/1</a></h3>
  43. <div class="spec">
  44. <p><tt>check_children(Pid) -&gt; any()</tt></p>
  45. </div><p>Check children, try restarting children when they are in 'error' state.</p>
  46. <h3 class="function"><a name="code_change-3">code_change/3</a></h3>
  47. <div class="spec">
  48. <p><tt>code_change(OldVsn, State, Extra) -&gt; {ok, NewState}</tt></p>
  49. </div><p>Convert process state when code is changed</p>
  50. <h3 class="function"><a name="delete_child-2">delete_child/2</a></h3>
  51. <div class="spec">
  52. <p><tt>delete_child(Pid, Name) -&gt; any()</tt></p>
  53. </div><p>Delete a child, the child will be terminated and removed.</p>
  54. <h3 class="function"><a name="handle_call-3">handle_call/3</a></h3>
  55. <div class="spec">
  56. <p><tt>handle_call(Message::Request, From, State) -&gt; {reply, Reply, State} | {reply, Reply, State, Timeout} | {noreply, State} | {noreply, State, Timeout} | {stop, Reason, Reply, State} | {stop, Reason, State}</tt></p>
  57. </div><p>Add a child in the stopped state.</p>
  58. <h3 class="function"><a name="handle_cast-2">handle_cast/2</a></h3>
  59. <div class="spec">
  60. <p><tt>handle_cast(Message, State) -&gt; any()</tt></p>
  61. </div><p>Stop a child process and add it to the stopped list.</p>
  62. <h3 class="function"><a name="handle_info-2">handle_info/2</a></h3>
  63. <div class="spec">
  64. <p><tt>handle_info(Info, State) -&gt; {noreply, State} | {noreply, State, Timeout} | {stop, Reason, State}</tt></p>
  65. </div><p>Handle the exit of a child</p>
  66. <h3 class="function"><a name="init-1">init/1</a></h3>
  67. <div class="spec">
  68. <p><tt>init(InitialChildren::Args) -&gt; {ok, State} | {ok, State, Timeout} | ignore | {stop, Reason}</tt></p>
  69. </div><p>Initiates the server.</p>
  70. <h3 class="function"><a name="restart_child-2">restart_child/2</a></h3>
  71. <div class="spec">
  72. <p><tt>restart_child(Pid, Name) -&gt; any()</tt></p>
  73. </div><p>Terminate and restart a child.</p>
  74. <h3 class="function"><a name="running_children-1">running_children/1</a></h3>
  75. <div class="spec">
  76. <p><tt>running_children(Pid) -&gt; any()</tt></p>
  77. </div><p>Return the list of running children</p>
  78. <h3 class="function"><a name="set_manager_pid-2">set_manager_pid/2</a></h3>
  79. <div class="spec">
  80. <p><tt>set_manager_pid(Pid, ManagerPid) -&gt; any()</tt></p>
  81. </div><p>Set the manager pid for this supervisor</p>
  82. <h3 class="function"><a name="start_child-2">start_child/2</a></h3>
  83. <div class="spec">
  84. <p><tt>start_child(Pid, Name) -&gt; any()</tt></p>
  85. </div><p>Start a child when it is not running (either failed or stopped)</p>
  86. <h3 class="function"><a name="start_link-1">start_link/1</a></h3>
  87. <div class="spec">
  88. <p><tt>start_link(Args) -&gt; any()</tt></p>
  89. </div>
  90. <h3 class="function"><a name="start_link-2">start_link/2</a></h3>
  91. <div class="spec">
  92. <p><tt>start_link(SupName, Args) -&gt; any()</tt></p>
  93. </div>
  94. <h3 class="function"><a name="stop_child-2">stop_child/2</a></h3>
  95. <div class="spec">
  96. <p><tt>stop_child(Pid, Name) -&gt; any()</tt></p>
  97. </div><p>Stop a child, the child will be terminated and put in "stopped" state</p>
  98. <h3 class="function"><a name="terminate-2">terminate/2</a></h3>
  99. <div class="spec">
  100. <p><tt>terminate(Reason, State) -&gt; <a href="#type-void">void()</a></tt></p>
  101. </div><p>This function is called by a gen_server when it is about to
  102. terminate. It should be the opposite of Module:init/1 and do any necessary
  103. cleaning up. When it returns, the gen_server terminates with Reason.
  104. The return value is ignored.</p>
  105. <h3 class="function"><a name="which_children-1">which_children/1</a></h3>
  106. <div class="spec">
  107. <p><tt>which_children(Pid) -&gt; any()</tt></p>
  108. </div><p>Return the list of all children and their run state.</p>
  109. <hr>
  110. <div class="navbar"><a name="#navbar_bottom"></a><table width="100%" border="0" cellspacing="0" cellpadding="2" summary="navigation bar"><tr><td><a href="overview-summary.html" target="overviewFrame">Overview</a></td><td><a href="http://www.erlang.org/"><img src="erlang.png" align="right" border="0" alt="erlang logo"></a></td></tr></table></div>
  111. <p><i>Generated by EDoc, Oct 13 2011, 14:45:56.</i></p>
  112. </body>
  113. </html>