feat: support accessing PostgreSQL on unix domain sockets (#4456)

* Support configuring teslamate with unix domain sockets for Postgres

* docs

* reorder

* format, cleanup

* style: update environment variables documentation for DATABASE_SOCKET_DIR formatting

---------

Co-authored-by: Jakob Lichterfeld <jakob-lichterfeld@gmx.de>
This commit is contained in:
James Baker
2025-01-13 17:15:38 +01:00
committed by GitHub
co-authored by Jakob Lichterfeld
parent 61fc3b2627
commit 21d3b520e1
2 changed files with 19 additions and 10 deletions
+14 -6
View File
@@ -101,14 +101,22 @@ end
config :teslamate,
default_geofence: System.get_env("DEFAULT_GEOFENCE")
case System.get_env("DATABASE_SOCKET_DIR") do
nil ->
config :teslamate, TeslaMate.Repo,
username: Util.fetch_env!("DATABASE_USER", all: "postgres"),
password: Util.fetch_env!("DATABASE_PASS", all: "postgres"),
hostname: Util.fetch_env!("DATABASE_HOST", all: "localhost"),
port: System.get_env("DATABASE_PORT", "5432")
socket_dir ->
config :teslamate, TeslaMate.Repo, socket_dir: socket_dir
end
config :teslamate, TeslaMate.Repo,
username: Util.fetch_env!("DATABASE_USER", all: "postgres"),
password: Util.fetch_env!("DATABASE_PASS", all: "postgres"),
database: Util.fetch_env!("DATABASE_NAME", dev: "teslamate_dev", test: "teslamate_test"),
hostname: Util.fetch_env!("DATABASE_HOST", all: "localhost"),
port: System.get_env("DATABASE_PORT", "5432"),
pool_size: System.get_env("DATABASE_POOL_SIZE", "10") |> String.to_integer(),
timeout: System.get_env("DATABASE_TIMEOUT", "60000") |> String.to_integer()
timeout: System.get_env("DATABASE_TIMEOUT", "60000") |> String.to_integer(),
database: Util.fetch_env!("DATABASE_NAME", dev: "teslamate_dev", test: "teslamate_test")
case System.get_env("DATABASE_SSL") do
"true" ->