diff --git a/apps/fz_http/lib/fz_http/connectivity_check_service.ex b/apps/fz_http/lib/fz_http/connectivity_check_service.ex index 65693017d..8ce78c9d5 100644 --- a/apps/fz_http/lib/fz_http/connectivity_check_service.ex +++ b/apps/fz_http/lib/fz_http/connectivity_check_service.ex @@ -9,6 +9,10 @@ defmodule FzHttp.ConnectivityCheckService do alias FzHttp.ConnectivityChecks + # Wait a minute before sending the first ping to avoid event spamming when + # a container is stuck in a reboot loop. + @initial_delay 60 * 1_000 + def start_link(_) do http_client().start() GenServer.start_link(__MODULE__, %{}) @@ -17,7 +21,7 @@ defmodule FzHttp.ConnectivityCheckService do @impl GenServer def init(state) do if enabled?() do - :timer.send_interval(interval(), :perform) + :timer.send_after(@initial_delay, :perform) end {:ok, state} @@ -26,6 +30,7 @@ defmodule FzHttp.ConnectivityCheckService do # XXX: Consider passing state here to implement exponential backoff in case of errors. @impl GenServer def handle_info(:perform, _state) do + :timer.send_interval(interval(), :perform) {:noreply, post_request()} end diff --git a/apps/fz_http/lib/fz_http/telemetry_ping_service.ex b/apps/fz_http/lib/fz_http/telemetry_ping_service.ex index c79126ac4..f56aed9df 100644 --- a/apps/fz_http/lib/fz_http/telemetry_ping_service.ex +++ b/apps/fz_http/lib/fz_http/telemetry_ping_service.ex @@ -6,7 +6,8 @@ defmodule FzHttp.TelemetryPingService do use GenServer alias FzHttp.Telemetry - @interval 3_600 + @initial_delay 60 * 1_000 + @interval 43_200 def start_link(_) do GenServer.start_link(__MODULE__, %{}) @@ -14,14 +15,16 @@ defmodule FzHttp.TelemetryPingService do @impl GenServer def init(state) do - # Send ping every hour - :timer.send_interval(@interval * 1000, :perform) + # Send ping after 1 minute + :timer.send_after(@initial_delay, :perform) {:ok, state} end @impl GenServer def handle_info(:perform, state) do Telemetry.ping() + # Continue pinging twice a day + :timer.send_interval(@interval * 1_000, :perform) {:noreply, state} end end diff --git a/apps/fz_http/lib/fz_http_web/sockets/user_socket.ex b/apps/fz_http/lib/fz_http_web/sockets/user_socket.ex index d7d75a28f..d52c7ad9b 100644 --- a/apps/fz_http/lib/fz_http_web/sockets/user_socket.ex +++ b/apps/fz_http/lib/fz_http_web/sockets/user_socket.ex @@ -8,7 +8,7 @@ defmodule FzHttpWeb.UserSocket do https://docs.firezone.dev/deploy/reverse-proxies?utm_source=code \ """ - # 4 hour channel tokens + # 1 day channel tokens @token_verify_opts [max_age: 86_400] require Logger diff --git a/config/config.exs b/config/config.exs index 79476e8c3..8271cbfb4 100644 --- a/config/config.exs +++ b/config/config.exs @@ -6,7 +6,7 @@ config :phoenix, :json_library, Jason # Public API key for telemetry config :posthog, api_url: "https://t.firez.one", - api_key: "phc_xnIRwzHSaI6c81ukilv09w2TRWUJIRo4VCxshvl7znY" + api_key: "phc_ubuPhiqqjMdedpmbWpG2Ak3axqv5eMVhFDNBaXl9UZK" # Guardian configuration config :fz_http, FzHttpWeb.Auth.HTML.Authentication, @@ -39,7 +39,7 @@ config :fz_http, supervision_tree_mode: :full, http_client: HTTPoison, connectivity_checks_enabled: true, - connectivity_checks_interval: 3_600, + connectivity_checks_interval: 43_200, connectivity_checks_url: "https://ping-dev.firez.one/", cookie_secure: true, cookie_signing_salt: "Z9eq8iof", diff --git a/config/runtime.exs b/config/runtime.exs index 62e4fe445..0ec550581 100644 --- a/config/runtime.exs +++ b/config/runtime.exs @@ -131,7 +131,7 @@ if config_env() == :prod do System.get_env("CI") != "true" connectivity_checks_interval = - System.get_env("CONNECTIVITY_CHECKS_INTERVAL", "3600") + System.get_env("CONNECTIVITY_CHECKS_INTERVAL", "43200") |> String.to_integer() |> FzInteger.clamp(60, 86_400) diff --git a/config/test.exs b/config/test.exs index acbc014f1..bbae70e30 100644 --- a/config/test.exs +++ b/config/test.exs @@ -41,7 +41,7 @@ config :fz_http, mock_events_module_errors: false, telemetry_module: FzCommon.MockTelemetry, supervision_tree_mode: :test, - connectivity_checks_interval: 86_400, + connectivity_checks_interval: 43_200, sql_sandbox: true, http_client: FzHttp.Mocks.HttpClient diff --git a/docs/static/js/posthog.js b/docs/static/js/posthog.js index bdfbccb77..4a71be7f9 100644 --- a/docs/static/js/posthog.js +++ b/docs/static/js/posthog.js @@ -1,2 +1,2 @@ !function(t,e){var o,n,p,r;e.__SV||(window.posthog=e,e._i=[],e.init=function(i,s,a){function g(t,e){var o=e.split(".");2==o.length&&(t=t[o[0]],e=o[1]),t[e]=function(){t.push([e].concat(Array.prototype.slice.call(arguments,0)))}}(p=t.createElement("script")).type="text/javascript",p.async=!0,p.src=s.api_host+"/static/array.js",(r=t.getElementsByTagName("script")[0]).parentNode.insertBefore(p,r);var u=e;for(void 0!==a?u=e[a]=[]:a="posthog",u.people=u.people||[],u.toString=function(t){var e="posthog";return"posthog"!==a&&(e+="."+a),t||(e+=" (stub)"),e},u.people.toString=function(){return u.toString(1)+".people (stub)"},o="capture identify alias people.set people.set_once set_config register register_once unregister opt_out_capturing has_opted_out_capturing opt_in_capturing reset isFeatureEnabled onFeatureFlags".split(" "),n=0;n