Skip to content

Commit

Permalink
Pass shutdown_timeout to terminator supervisor
Browse files Browse the repository at this point in the history
  • Loading branch information
chrismccord committed Mar 8, 2024
1 parent 3a03d21 commit 82f6073
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
8 changes: 3 additions & 5 deletions lib/application.ex
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,13 @@ defmodule FLAME.Application do

@impl true
def start(_type, _args) do
{shutdown_timeout, opts} =
:flame
|> Application.get_env(:terminator, [])
|> Keyword.pop(:shutdown_timeout, 30_000)
opts = Application.get_env(:flame, :terminator, [])
shutdown = Keyword.get(opts, :shutdown_timeout, 30_000)

opts = Keyword.put(opts, :name, FLAME.Terminator)

children = [
Supervisor.child_spec({FLAME.Terminator, opts}, shutdown: shutdown_timeout)
Supervisor.child_spec({FLAME.Terminator, opts}, shutdown: shutdown)
]

opts = [strategy: :one_for_one, name: FLAME.Supervisor]
Expand Down
3 changes: 2 additions & 1 deletion lib/flame/terminator/supervisor.ex
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ defmodule FLAME.Terminator.Supervisor do
end

def init(opts) do
{shutdown_timeout, opts} = Keyword.pop(opts, :shutdown_timeout, 30_000)
name = Keyword.fetch!(opts, :name)
child_placement_sup = child_placement_sup_name(name)
terminator_opts = Keyword.merge(opts, child_placement_sup: child_placement_sup)
Expand All @@ -27,7 +28,7 @@ defmodule FLAME.Terminator.Supervisor do
id: FLAME.Terminator,
start: {FLAME.Terminator, :start_link, [terminator_opts]},
type: :worker,
shutdown: opts[:shutdown_timeout] || 30_000
shutdown: shutdown_timeout
}
]

Expand Down

0 comments on commit 82f6073

Please sign in to comment.