I am running into a problem when trying to use Distillery to get system variables at run time. Currently, I have defined the connection to the database as so:
config :myapp, MyApp.Repo,
adapter: Ecto.Adapters.Postgres,
timeout: 2000000,
username: "${DB_USER}",
password: "${DB_PASSWORD}",
database: "${DB_DATABASE}",
hostname: "${DB_HOST}",
port: 5432,
pool_size: 10
Then, I am running phx.digest and mix release to get my tar file. I then deploy this tar file using a systemd configuration that I run on my ubuntu server which has all the environment variables set. These are the important lines of the systemd service:
[Service]
Type=forking
WorkingDirectory=/opt/app
User=ubuntu
RemainAfterExit=yes
Restart=on-failure
RestartSec=5
Environment=MIX_ENV=stage "PORT=4000"
Environment=LANG=en_US.UTF-8
Environment=REPLACE_OS_VARS=true
EnvironmentFile=/etc/profile
ExecStart=/opt/app/bin/myapp migrate-start
ExecStop=/opt/app/bin/myapp stop
ExecReload=/opt/app/bin/myapp restart
SyslogIdentifier=myapp
When I try to run this service on the server instance. It is trying to connect to ${DB_HOST}:5432 as the url and is not evaluating that I wan't to replace that with a configured value. I have run successfully run this before using hardcoded values so I know the issue is with replacing the values. Does anyone have any suggestions to how I can fix this error? I have all the necessary values set on the server, including REPLACE_OS_VARS=true set again.
Any help or guidance is appreciated.