Skip to content

Commit b2e3c20

Browse files
committed
make worker sup temporary
1 parent 4a70624 commit b2e3c20

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

lib/pool_toy/pool_man.ex

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ defmodule PoolToy.PoolMan do
8888

8989
def handle_info(:start_worker_sup, %State{pool_sup: sup} = state) do
9090
{:ok, worker_sup} = Supervisor.start_child(sup, PoolToy.WorkerSup)
91+
Process.link(worker_sup)
9192

9293
state =
9394
state
@@ -107,6 +108,10 @@ defmodule PoolToy.PoolMan do
107108
end
108109
end
109110

111+
def handle_info({:EXIT, pid, reason}, %State{worker_sup: pid} = state) do
112+
{:stop, {:worker_sup_exit, reason}, state}
113+
end
114+
110115
def handle_info({:EXIT, pid, _reason}, %State{workers: workers, monitors: monitors} = state) do
111116
case :ets.lookup(monitors, pid) do
112117
[{pid, ref}] ->

lib/pool_toy/worker_sup.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
defmodule PoolToy.WorkerSup do
2-
use DynamicSupervisor
2+
use DynamicSupervisor, restart: :temporary
33

44
def start_link(args) do
55
DynamicSupervisor.start_link(__MODULE__, args)

0 commit comments

Comments
 (0)