File tree Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -25,14 +25,23 @@ defmodule Task.Supervisor do
25
25
described under the `Name Registration` section in the `GenServer` module
26
26
docs;
27
27
28
+ * `:restart` - the restart strategy, may be `:temporary` (the default),
29
+ `:transient` or `:permanent`. Check `Supervisor.Spec` for more info.
30
+ Defaults to temporary as most tasks can't be effectively restarted after
31
+ a crash;
32
+
28
33
* `:shutdown` - `:brutal_kill` if the tasks must be killed directly on shutdown
29
34
or an integer indicating the timeout value, defaults to 5000 milliseconds;
35
+
36
+ * `:max_restarts` and `:max_seconds` - as specified in `Supervisor.Spec.supervise/2`;
37
+
30
38
"""
31
39
@ spec start_link ( Supervisor . options ) :: Supervisor . on_start
32
40
def start_link ( opts \\ [ ] ) do
33
41
import Supervisor.Spec
42
+ { restart , opts } = Keyword . pop ( opts , :restart , :temporary )
34
43
{ shutdown , opts } = Keyword . pop ( opts , :shutdown , 5000 )
35
- children = [ worker ( Task.Supervised , [ ] , restart: :temporary , shutdown: shutdown ) ]
44
+ children = [ worker ( Task.Supervised , [ ] , restart: restart , shutdown: shutdown ) ]
36
45
Supervisor . start_link ( children , [ strategy: :simple_one_for_one ] ++ opts )
37
46
end
38
47
You can’t perform that action at this time.
0 commit comments