Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support accessing PostgreSQL on unix domain sockets #4456

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 14 additions & 6 deletions config/runtime.exs
Original file line number Diff line number Diff line change
Expand Up @@ -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" ->
Expand Down
9 changes: 5 additions & 4 deletions website/docs/configuration/environment_variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@ TeslaMate accepts the following environment variables for runtime configuration:
| Variable Name | Description | Default Value |
| -------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------- |
| **ENCRYPTION_KEY** | A key used to encrypt the Tesla API tokens (**required**) | |
| **DATABASE_USER** | Username (**required**) | |
| **DATABASE_PASS** | User password (**required**) | |
| **DATABASE_NAME** | The database to connect to (**required**) | |
| **DATABASE_HOST** | Hostname of the database server (**required**) | |
| **DATABASE_USER** | Username | |
| **DATABASE_PASS** | User password | |
| **DATABASE_NAME** | The database to connect to | |
| **DATABASE_HOST** | Hostname of the database server | |
| **DATABASE_PORT** | Port of the database server | 5432 |
| **DATABASE_SOCKET_DIR** | Local path containing unix socket for database if that connection mechanic is preferred. Provide one of DATABASE*SOCKET_DIR and DATABASE*(USER\|PASS\|HOST\|PORT) | |
| **DATABASE_POOL_SIZE** | Size of the database connection pool | 10 |
| **DATABASE_TIMEOUT** | The time in milliseconds to wait for database query calls to finish | 60000 |
| **DATABASE_SSL** | Set to `true` if SSL should be enabled or `noverify` if certificate verification should not be performed. | false |
Expand Down
Loading