Reconnect to CeleryScript channel in the case of error

This was left out when we refactored this channel to
use `mox`
pull/974/head
Connor Rigby 2019-09-09 13:00:52 -07:00
parent cd9d45cddc
commit 40523670e1
No known key found for this signature in database
GPG Key ID: 29A88B24B70456E0
1 changed files with 8 additions and 1 deletions

View File

@ -140,8 +140,15 @@ defmodule FarmbotExt.AMQP.CeleryScriptChannel do
defp compute_reply_from_amqp_state(state, error) do
# Run error warning if error not nil
if error,
do: FarmbotCore.Logger.error(1, "Failed to connect to AutoSync channel: #{inspect(error)}")
do:
FarmbotCore.Logger.error(
1,
"Failed to connect to CeleryScript channel: #{inspect(error)}"
)
# Try to reconnect every 5 seconds. This should have some randomness
# sprinkled onto it in the case of mass disconnects etc.
Process.send_after(self(), :timeout, 5000)
{:noreply, %{state | conn: nil, chan: nil}}
end
end