working on redundancy

This commit is contained in:
2026-03-06 16:37:31 -07:00
parent 8059048db2
commit 181c6ca84b
16 changed files with 282 additions and 29 deletions

View File

@@ -51,6 +51,20 @@ config :logger, :console,
# Use Jason for JSON parsing in Phoenix
config :phoenix, :json_library, Jason
# Lower the BEAM node-down detection window from the default 60s.
# Nodes send ticks every (net_ticktime / 4)s; a node is declared down
# after 4 missed ticks (net_ticktime total). 5s means detection in ≤5s.
config :kernel, net_ticktime: 2
# Libcluster — Gossip strategy works for local dev and Docker Compose
# (UDP multicast, zero config). Overridden to Kubernetes.DNS in runtime.exs for prod.
config :libcluster,
topologies: [
gossip: [
strategy: Cluster.Strategy.Gossip
]
]
# Import environment specific config. This must remain at the bottom
# of this file so it overrides the configuration defined above.
import_config "#{config_env()}.exs"

View File

@@ -29,11 +29,6 @@ if System.get_env("PHX_SERVER") do
end
if config_env() == :prod do
# 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
# want to use a different value for prod and you most likely don't want
# to check this value into version control, so we use an environment
# variable instead.
secret_key_base =
System.get_env("SECRET_KEY_BASE") ||
raise """
@@ -41,6 +36,33 @@ if config_env() == :prod do
You can generate one by calling: mix phx.gen.secret
"""
database_url =
System.get_env("DATABASE_URL") ||
raise """
environment variable DATABASE_URL is missing.
For example: ecto://user:password@host/database
"""
config :elixir_ai, ElixirAi.Repo,
url: database_url,
pool_size: String.to_integer(System.get_env("POOL_SIZE") || "10")
# In Kubernetes, switch from Gossip to DNS-based discovery via a headless service.
# Set K8S_NAMESPACE and optionally K8S_SERVICE_NAME in your pod spec.
if System.get_env("K8S_NAMESPACE") do
config :libcluster,
topologies: [
k8s_dns: [
strategy: Cluster.Strategy.Kubernetes.DNS,
config: [
service: System.get_env("K8S_SERVICE_NAME") || "elixir-ai-headless",
application_name: "elixir_ai",
namespace: System.get_env("K8S_NAMESPACE")
]
]
]
end
host = System.get_env("PHX_HOST") || "example.com"
port = String.to_integer(System.get_env("PORT") || "4000")