diff --git a/lib/exq/manager/server.ex b/lib/exq/manager/server.ex index a4c7a0a0..17beed88 100644 --- a/lib/exq/manager/server.ex +++ b/lib/exq/manager/server.ex @@ -141,10 +141,6 @@ defmodule Exq.Manager.Server do ##=========================================================== def init(opts) do - - # Cleanup stale stats - GenServer.cast(self(), :cleanup_host_stats) - # Setup queues work_table = setup_queues(opts) @@ -166,6 +162,11 @@ defmodule Exq.Manager.Server do check_redis_connection(opts) + # Cleanup stale stats + rescue_timeout(fn -> + Exq.Stats.Server.cleanup_host_stats(state.stats, state.namespace, state.node_id, state.pid) + end) + HeartbeatServer.start_link(state) {:ok, state, 0} end @@ -216,16 +217,6 @@ defmodule Exq.Manager.Server do {:noreply, state, 0} end - @doc """ - Cleanup host stats on boot - """ - def handle_cast(:cleanup_host_stats, state) do - rescue_timeout(fn -> - Exq.Stats.Server.cleanup_host_stats(state.stats, state.namespace, state.node_id, state.pid) - end) - {:noreply, state, 0} - end - def handle_cast({:job_terminated, _namespace, queue, _job_serialized}, state) do update_worker_count(state.work_table, queue, -1) {:noreply, state, 0}