Skip to content

Commit

Permalink
Configure libcluster_postgres from DATABASE_URL
Browse files Browse the repository at this point in the history
  • Loading branch information
IvanIvanoff committed Dec 17, 2024
1 parent f77baa3 commit c5bbac4
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions config/runtime.exs
Original file line number Diff line number Diff line change
Expand Up @@ -95,15 +95,20 @@ if config_env() == :prod do
ssl: true,
ssl_opts: [verify: :verify_none]

db_url = System.get_env("DATABASE_URL")
uri = URI.parse(db_url)
[username, password] = String.split(uri.userinfo, ":")
database = String.split(db_url, "/") |> List.last()

config :libcluster,
topologies: [
postgres_topology: [
strategy: LibclusterPostgres.Strategy,
config: [
hostname: "localhost",
username: "postgres",
password: "postgres",
database: "santiment",
hostname: uri.host,
username: username,
password: password,
database: database,
port: 5432,
parameters: [],
ssl: true,
Expand Down

0 comments on commit c5bbac4

Please sign in to comment.