diff --git a/lib/oban/queue/supervisor.ex b/lib/oban/queue/supervisor.ex index 947f8c8d..f9e06ef6 100644 --- a/lib/oban/queue/supervisor.ex +++ b/lib/oban/queue/supervisor.ex @@ -38,6 +38,7 @@ defmodule Oban.Queue.Supervisor do watch_opts = [ foreman: fore_name, name: watch_name, + producer: prod_name, shutdown: conf.shutdown_grace_period ] diff --git a/lib/oban/queue/watchman.ex b/lib/oban/queue/watchman.ex index 20305b16..e39027de 100644 --- a/lib/oban/queue/watchman.ex +++ b/lib/oban/queue/watchman.ex @@ -3,15 +3,18 @@ defmodule Oban.Queue.Watchman do use GenServer + alias Oban.Queue.Producer + @type option :: - {:name, module()} - | {:foreman, identifier()} + {:foreman, GenServer.name()} + | {:name, module()} + | {:producer, GenServer.name()} | {:shutdown, timeout()} defmodule State do @moduledoc false - defstruct [:foreman, :shutdown, interval: 10] + defstruct [:foreman, :producer, :shutdown, interval: 10] end @spec child_spec([option]) :: Supervisor.child_spec() @@ -47,6 +50,7 @@ defmodule Oban.Queue.Watchman do # There is a chance that the foreman doesn't exist, and we never want to raise another error # as part of the shut down process. try do + :ok = Producer.shutdown(state.producer) :ok = wait_for_executing(state) catch :exit, _reason -> :ok diff --git a/test/oban_test.exs b/test/oban_test.exs index f8faccce..74581ce8 100644 --- a/test/oban_test.exs +++ b/test/oban_test.exs @@ -58,7 +58,7 @@ defmodule ObanTest do name = start_supervised_oban!( queues: [alpha: 1], - shutdown_grace_period: 10, + shutdown_grace_period: 40, stage_interval: 10 )