| 1 |
|
defmodule Elita.Infra do |
| 2 |
|
import Supervisor, only: [start_link: 2] |
| 3 |
|
import System, only: [get_env: 1] |
| 4 |
|
|
| 5 |
|
@spec_map %{ |
| 6 |
|
id: __MODULE__, |
| 7 |
|
start: {__MODULE__, :start_link, [nil]}, |
| 8 |
|
type: :supervisor, |
| 9 |
|
restart: :permanent, |
| 10 |
|
shutdown: :infinity |
| 11 |
|
} |
| 12 |
|
|
| 13 |
1 |
def child_spec(_arg), do: @spec_map |
| 14 |
|
|
| 15 |
|
def start_link(_arg) do |
| 16 |
1 |
start_link(specs(), opts()) |
| 17 |
|
end |
| 18 |
|
|
| 19 |
|
defp specs do |
| 20 |
1 |
tapes(get_env("TAPE")) |
| 21 |
|
end |
| 22 |
|
|
| 23 |
1 |
defp tapes(nil), do: [] |
| 24 |
:-( |
defp tapes(_), do: [tape()] |
| 25 |
|
|
| 26 |
|
defp tape do |
| 27 |
:-( |
%{id: Tape.Writer, start: {Tape.Writer, :start_link, [nil]}} |
| 28 |
|
end |
| 29 |
|
|
| 30 |
1 |
defp opts, |
| 31 |
|
do: [ |
| 32 |
|
strategy: :one_for_one, |
| 33 |
|
name: Elita.Infra, |
| 34 |
|
max_restarts: 3, |
| 35 |
|
max_seconds: 30 |
| 36 |
|
] |
| 37 |
|
end |