diff --git a/config/runtime.exs b/config/runtime.exs index 8ac15c4..20a739e 100644 --- a/config/runtime.exs +++ b/config/runtime.exs @@ -44,7 +44,7 @@ config :ash_hq, Oban, Oban.Plugins.Pruner, {Oban.Plugins.Cron, crontab: []} ], - queues: [importer: [limit: 3, paused: not (periodic_imports? || config_env() == :prod)]] + queues: [importer: [limit: 1, paused: not (periodic_imports? || config_env() == :prod)]] if config_env() == :prod do app_name = @@ -85,7 +85,7 @@ if config_env() == :prod do config :flame, :backend, FLAME.FlyBackend config :flame, FLAME.FlyBackend, token: System.fetch_env!("FLY_API_TOKEN") - config :flame, :terminator, shutdown_timeout: :timer.minutes(10) + config :flame, :terminator, shutdown_timeout: :timer.seconds(30) # The secret key base is used to sign/encrypt cookies and other secrets. # A default value is used in config/dev.exs and config/test.exs but you diff --git a/lib/ash_hq/application.ex b/lib/ash_hq/application.ex index b577781..9421e5f 100644 --- a/lib/ash_hq/application.ex +++ b/lib/ash_hq/application.ex @@ -11,16 +11,12 @@ defmodule AshHq.Application do Appsignal.Phoenix.LiveView.attach() - topologies = Application.get_env(:libcluster, :topologies) || [] + # topologies = Application.get_env(:libcluster, :topologies) || [] children = [ {FLAME.Pool, - name: AshHq.ImporterPool, - min: 0, - max: 1, - max_concurrency: 10, - idle_shutdown_after: 30_000}, + name: AshHq.ImporterPool, min: 0, max: 1, max_concurrency: 1, idle_shutdown_after: 30_000}, !flame_parent && Supervisor.child_spec({Finch, name: AshHq.Finch}, id: AshHq.Finch), !flame_parent && Supervisor.child_spec({Finch, name: Swoosh.Finch}, id: Swoosh.Finch), AshHq.Vault, @@ -32,10 +28,11 @@ defmodule AshHq.Application do # Start the PubSub system {Phoenix.PubSub, name: AshHq.PubSub}, # Start the Endpoint (http/https) - !flame_parent && AshHqWeb.Endpoint, + AshHqWeb.Endpoint, {AshHq.Docs.Library.Agent, nil}, # !flame_parent && {Cluster.Supervisor, [topologies, [name: AshHq.ClusterSupervisor]]}, {Haystack.Storage.ETS, storage: AshHq.Docs.Indexer.storage()}, + !flame_parent && {Cluster.Supervisor, [topologies, [name: AshHq.ClusterSupervisor]]}, !flame_parent && AshHq.Docs.Indexer, !flame_parent && AshHq.Github.Monitor, !flame_parent && oban_worker(), diff --git a/lib/ash_hq/docs/resources/library/actions/import.ex b/lib/ash_hq/docs/resources/library/actions/import.ex index 168933f..7765d89 100644 --- a/lib/ash_hq/docs/resources/library/actions/import.ex +++ b/lib/ash_hq/docs/resources/library/actions/import.ex @@ -71,26 +71,36 @@ defmodule AshHq.Docs.Library.Actions.Import do if result do Logger.info("Starting import of #{name}: #{version}") - delete_except( - AshHq.Docs.load!(library, :latest_version_id).latest_version_id, - library.id - ) + unless AshHq.Docs.exists?( + Ash.Query.for_read(AshHq.Docs.LibraryVersion, :read) + |> Ash.Query.filter(library_id == ^library.id and version == ^version) + ) do + AshHq.SqliteRepo.transaction( + fn -> + delete_except( + AshHq.Docs.load!(library, :latest_version_id).latest_version_id, + library.id + ) - library_version = - AshHq.Docs.LibraryVersion.build!( - library.id, - version, - %{ - timeout: :infinity, - extensions: result[:extensions], - doc: result[:doc], - guides: result[:guides], - modules: result[:modules], - mix_tasks: result[:mix_tasks] - } + library_version = + AshHq.Docs.LibraryVersion.build!( + library.id, + version, + %{ + timeout: :infinity, + extensions: result[:extensions], + doc: result[:doc], + guides: result[:guides], + modules: result[:modules], + mix_tasks: result[:mix_tasks] + } + ) + + delete_except(library_version.id, library.id) + end, + timeout: :infinity ) - - delete_except(library_version.id, library.id) + end end end diff --git a/lib/ash_hq/docs/resources/library/library.ex b/lib/ash_hq/docs/resources/library/library.ex index 3e0a48c..e5bd69e 100644 --- a/lib/ash_hq/docs/resources/library/library.ex +++ b/lib/ash_hq/docs/resources/library/library.ex @@ -51,17 +51,18 @@ defmodule AshHq.Docs.Library do ] end - change fn changeset, _ -> - Ash.Changeset.around_transaction(changeset, fn changeset, func -> - FLAME.call( - AshHq.ImporterPool, - fn -> - func.(changeset) - end, - timeout: :timer.minutes(10) - ) - end) - end + # litefs can't write from another node, so we had to turn this off + # change fn changeset, _ -> + # Ash.Changeset.around_transaction(changeset, fn changeset, func -> + # FLAME.call( + # AshHq.ImporterPool, + # fn -> + # func.(changeset) + # end, + # timeout: :timer.minutes(10) + # ) + # end) + # end manual AshHq.Docs.Library.Actions.Import end diff --git a/priv/scripts/build_dsl_docs.exs b/priv/scripts/build_dsl_docs.exs index a5013c8..831cdb2 100644 --- a/priv/scripts/build_dsl_docs.exs +++ b/priv/scripts/build_dsl_docs.exs @@ -711,7 +711,7 @@ defmodule Utils do |> Map.new() |> Map.put(:order, index) |> Map.put(:route, route) - |> Map.put(:category, category) + |> Map.put(:category, List.first(List.wrap(category))) |> Map.put(:text, File.read!(path)) end) end) diff --git a/rel/env.sh.eex b/rel/env.sh.eex index 7d3967c..7fe3ad9 100644 --- a/rel/env.sh.eex +++ b/rel/env.sh.eex @@ -4,4 +4,5 @@ export ERL_AFLAGS="-proto_dist inet6_tcp" export ECTO_IPV6="true" export DNS_CLUSTER_QUERY="${FLY_APP_NAME}.internal" export RELEASE_DISTRIBUTION="name" -export RELEASE_NODE="${FLY_APP_NAME}-${FLY_IMAGE_REF##*-}@${FLY_PRIVATE_IP}" \ No newline at end of file +export RELEASE_NODE="${FLY_APP_NAME}-${FLY_IMAGE_REF##*-}@${FLY_PRIVATE_IP}" +export RELEASE_COOKIE="ash-hq-app" \ No newline at end of file