Skip to content

Commit

Permalink
Clean up stats at init of server
Browse files Browse the repository at this point in the history
  • Loading branch information
TondaHack committed Jan 29, 2018
1 parent 28da15d commit e7c2058
Showing 1 changed file with 5 additions and 14 deletions.
19 changes: 5 additions & 14 deletions lib/exq/manager/server.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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
Expand Down Expand Up @@ -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}
Expand Down

0 comments on commit e7c2058

Please sign in to comment.