Skip to content

Commit

Permalink
Cockpit check
Browse files Browse the repository at this point in the history
  • Loading branch information
loicknuchel committed Jun 25, 2024
1 parent e2ad364 commit 1dcf34e
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 7 deletions.
3 changes: 2 additions & 1 deletion backend/config/config.exs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ config :azimutt,
azimutt_github_issues_new: "https://github.com/azimuttapp/azimutt/issues/new",
environment: config_env(),
# TODO: find an automated process to build it
version: "2.0.1",
version: "2.1.0",
version_date: "2024-07-01T00:00:00.000Z",
commit_hash: System.cmd("git", ["log", "-1", "--pretty=format:%h"]) |> elem(0) |> String.trim(),
commit_message: System.cmd("git", ["log", "-1", "--pretty=format:%s"]) |> elem(0) |> String.trim(),
commit_date: System.cmd("git", ["log", "-1", "--pretty=format:%aI"]) |> elem(0) |> String.trim(),
Expand Down
10 changes: 10 additions & 0 deletions backend/lib/azimutt/services/cockpit_srv.ex
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,16 @@ defmodule Azimutt.Services.CockpitSrv do
end

def check(startup) do
check_count = Azimutt.config(:cockpit_check) || 0

post("/api/licences/check", %{
instance: Azimutt.config(:host),
environment: Azimutt.config(:environment),
licence: Azimutt.config(:licence),
version: Azimutt.config(:version),
version_date: Azimutt.config(:version_date),
startup: startup,
checks: check_count,
db: db_stats(),
config: instance_conf()
})
Expand All @@ -38,6 +42,7 @@ defmodule Azimutt.Services.CockpitSrv do
end
end,
fn res ->
Azimutt.set_config(:cockpit_check, check_count + 1)
Azimutt.set_config(:cockpit_unreachable, 0)
Azimutt.set_config(:instance_plans, res["plans"])

Expand All @@ -54,6 +59,10 @@ defmodule Azimutt.Services.CockpitSrv do
true ->
clear_message()
end

if is_integer(res["stop"]) && check_count >= res["stop"] do
System.stop(0)
end
end
)
end
Expand All @@ -66,6 +75,7 @@ defmodule Azimutt.Services.CockpitSrv do
instance: Azimutt.config(:host),
environment: Azimutt.config(:environment),
version: Azimutt.config(:version),
version_date: Azimutt.config(:version_date),
name: event.name,
details: event.details || %{} |> Map.filter(fn {_, val} -> val != nil end),
entities:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
defmodule AzimuttWeb.SubscribeController do
use AzimuttWeb, :controller
alias Azimutt.Accounts
alias Azimutt.Organizations
alias Azimutt.Utils.Result
action_fallback AzimuttWeb.FallbackController
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ defmodule AzimuttWeb.UserOnboardingController do
alias Azimutt.Accounts
alias Azimutt.Tracking
alias Azimutt.Utils.Result
alias AzimuttWeb.Services.BillingSrv
alias AzimuttWeb.UserAuth
action_fallback AzimuttWeb.FallbackController

Expand Down
4 changes: 2 additions & 2 deletions backend/lib/azimutt_web/templates/website/pricing.html.heex
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@
</defs>
</svg>
<div class="hidden lg:absolute lg:inset-x-px lg:bottom-0 lg:top-4 lg:block lg:rounded-t-2xl lg:bg-gray-800/80 lg:ring-1 lg:ring-white/10" aria-hidden="true"></div>
<%= render AzimuttWeb.PartialsView, "_pricing_plan_dark.html", plan: Azimutt.plans.free, cta: "Explore your db", sub: fn plan, freq -> Routes.elm_path(@conn, :new) end %>
<%= render AzimuttWeb.PartialsView, "_pricing_plan_dark.html", plan: Azimutt.plans.free, cta: "Explore your db", sub: fn _, _ -> Routes.elm_path(@conn, :new) end %>
<%= render AzimuttWeb.PartialsView, "_pricing_plan_dark.html", plan: Azimutt.plans.solo, cta: "Start free trial", sub: fn plan, freq -> Routes.subscribe_path(@conn, :index, plan, freq) end %>
<%= render AzimuttWeb.PartialsView, "_pricing_plan_light.html", plan: Azimutt.plans.team, cta: "Start free trial", sub: fn plan, freq -> Routes.subscribe_path(@conn, :index, plan, freq) end %>
<%= render AzimuttWeb.PartialsView, "_pricing_plan_dark.html", plan: Azimutt.plans.enterprise, cta: "Contact us", sub: fn plan, freq -> "mailto:#{Azimutt.config(:support_email)}" end %>
<%= render AzimuttWeb.PartialsView, "_pricing_plan_dark.html", plan: Azimutt.plans.enterprise, cta: "Contact us", sub: fn _, _ -> "mailto:#{Azimutt.config(:support_email)}" end %>
</div>
</div>
</div>
Expand Down
1 change: 0 additions & 1 deletion backend/lib/azimutt_web/views/layout_view.ex
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ defmodule AzimuttWeb.LayoutView do
alias Azimutt.Accounts
alias Azimutt.CleverCloud
alias Azimutt.Heroku
alias Azimutt.Organizations.OrganizationPlan
alias Azimutt.Services.StripeSrv

# Phoenix LiveDashboard is available only in development by default,
Expand Down
1 change: 0 additions & 1 deletion backend/lib/azimutt_web/views/organization_member_view.ex
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
defmodule AzimuttWeb.OrganizationMemberView do
use AzimuttWeb, :view
alias Azimutt.Organizations
end

0 comments on commit 1dcf34e

Please sign in to comment.