1
0
Fork 0
mirror of https://github.com/benbusby/farside.git synced 2025-06-20 16:26:36 +00:00

race condition i banish thee

This commit is contained in:
mithereal 2022-09-15 22:54:47 -07:00
parent b5378f85c6
commit 0e17984d6f
15 changed files with 498 additions and 186 deletions
lib/farside

33
lib/farside/deadcheck.ex Normal file
View file

@ -0,0 +1,33 @@
defmodule Farside.Server.DeadCheck do
@moduledoc """
Module to check/validate the instance list only for servers with empty instance list every 90 secs, if a sync/check process isnt already running
"""
use Task
def child_spec(args) do
%{
id: __MODULE__,
start: {__MODULE__, :start_link, [args]},
type: :worker
}
end
def start_link(_arg) do
Task.start_link(&poll/0)
end
def poll() do
receive do
after
1_200_000 ->
run()
poll()
end
end
def run() do
Registry.dispatch(:status, "dead", fn entries ->
for {pid, _} <- entries, do: GenServer.cast(pid, :check)
end)
end
end