Deploy two apps with differernt configs(edeliver and distillery)

I want to deploy staging and production/dev(for now on the same server). I am using distillery and edeliver with prod.secret.exs and environment variables. But neither environment variables or prod.secret.exs works the way I wanted. prod.secret.exs only works at compile time and environment variables are global. Any workaround I can make get some variables e.g database credentials and ports dynamically?

Thanks(Any help is really appreciated)

:wave:

You can specify env vars per process.

Sorry I did not get your point

Do you run the apps on separate beam instances? If so, you can specify the env vars separately for each before starting them.

Env vars don’t have to be global, you can specify them for each OS processes separately. That is, if you run your two apps in different OS processes.

1 Like

I dont know much about BEAM instances. but I think you mean using different LINK_SYS_CONFIG(ie. per beam process?) and here is what my .deliver/config looks like

BUILD_HOST="dev05api.haitracker.com"
BUILD_USER="tanweer"
BUILD_AT="/home/tanweer/app_build"

if [[ "$DEPLOY_ENVIRONMENT" = "staging" ]]; then
  STAGING_HOSTS="dev05api.haitracker.com"
  STAGING_USER="tanweer"
  DELIVER_TO="/home/tanweer/staging/app_release"
elif [[ "$DEPLOY_ENVIRONMENT" = "production" ]]; then
  PRODUCTION_HOSTS="dev05api.haitracker.com"
  PRODUCTION_USER="tanweer"
  DELIVER_TO="/home/tanweer/production/app_release"
fi

LINK_SYS_CONFIG="$DELIVER_TO/haitracker.config"

But now I am getting cat: /home/tanweer/production/app_release/haitracker/releases/0.1.3/sys.config: No such file or directory error. although it should look for /home/tanweer/production/app_release/haitracker.config file but it doesnt, (still looking for ...releases/0.1.3/sys.config, dont know if thats how its supposed to be.)

I’ve never used ediliver, but it probably already runs separate releases on separate vms, so you just need to specify env vars to be used for each separately.

ok So I am on the right track. Just need to figure out to pick right config file

You probably don’t need to use sys.config to achieve what you want … Just to be clear, my suggestion was to use env vars specific for each app.

I am already using env variables. which will be of course same when sourced from a .profile

Then try making .profile app-specific, I guess. You can create two user accounts on your machine, one for staging and one for production with each having their own .profile. But yeah, I wouldn’t use .profile for configuring apps.

I am going with different users on the machine. Thanks

Try looking into something like systemd for a simpler approach.

1 Like

Now I need to have two erlang node names configure dynamic erlang node name