単純なスーパーバイザー構成があります。
-module(my_supervisor).
-behaviour(supervisor).
-export([start_link/0, init/1]).
init(_Args) ->
{ok, { {one_for_one, 5, 10},
[
{my_worker, {my_worker, start_link, []}, permanent, 5000, worker, [my_worker]}
]
}
}.
そして単純な労働者でさえ:
-module(my_worker).
-export([start_link/0]).
start_link() ->
%??? is this the first time the supervisor is starting me or have I crashed and been restarted???
では、start_link関数がスーパーバイザーによって初めて呼び出されたのか、ワーカープロセスが過去にクラッシュして現在再起動されているのかを判断することも可能ですか?