Skip to content

Commit

Permalink
Allow the deployment calculator interval to be changed (#1537)
Browse files Browse the repository at this point in the history
* Allow the deployment calculator interval to be changed

* Set the default interval to 1 hour

Co-authored-by: Frank Hunleth <fhunleth@troodon-software.com>

---------

Co-authored-by: Frank Hunleth <fhunleth@troodon-software.com>
  • Loading branch information
joshk and fhunleth authored Sep 24, 2024
1 parent 484a72f commit 80f7e3d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 2 additions & 0 deletions config/runtime.exs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ config :nerves_hub,
String.to_integer(System.get_env("DEVICE_DEPLOYMENT_CHANGE_JITTER_SECONDS", "10")),
device_last_seen_update_interval_minutes:
String.to_integer(System.get_env("DEVICE_LAST_SEEN_UPDATE_INTERVAL_MINUTES", "5")),
deployment_calculator_interval_seconds:
String.to_integer(System.get_env("DEPLOYMENT_CALCULATOR_INTERVAL_SECONDS", "3600")),
mapbox_access_token: System.get_env("MAPBOX_ACCESS_TOKEN"),
dashboard_enabled: System.get_env("DASHBOARD_ENABLED", "false") == "true"

Expand Down
7 changes: 6 additions & 1 deletion lib/nerves_hub/deployments/calculator.ex
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ defmodule NervesHub.Deployments.Calculator do
{:noreply, %{state | process_timer_ref: nil}}

:none_found ->
timer_ref = Process.send_after(self(), :process_next_device, 15_000)
timer_ref = Process.send_after(self(), :process_next_device, not_found_retry_interval())

{:noreply, %{state | process_timer_ref: timer_ref}}
end
Expand All @@ -134,4 +134,9 @@ defmodule NervesHub.Deployments.Calculator do

# Catch all for unknown broadcasts on a deployment
def handle_info(%Broadcast{topic: "deployment:" <> _}, deployment), do: {:noreply, deployment}

defp not_found_retry_interval() do
Application.get_env(:nerves_hub, :deployment_calculator_interval_seconds)
|> :timer.seconds()
end
end

0 comments on commit 80f7e3d

Please sign in to comment.