phoenixframework/flame

fly machines don't always have env vars set in time

dustinfarris opened this issue · 1 comments

In my legacy fly deployment (generated pre-1.6.3), I'm occasionally having my flame-initiated application crash on startup when executing FLAME.call.

In my runtime.exs I have e.g. System.fetch_env!("BOX_ENTERPRISE_ID") and I'll get this in fly logs when flame executes

** (System.EnvError) could not fetch environment variable "BOX_ENTERPRISE_ID" because it is not set

This seems to only happen for environment variables I've set in fly.toml. It does not seem to happen for secrets I've set with fly secrets set.

I think the env vars are set late (after runtime.exs tries to look for them) because if I ssh into the running flame machine after the flame call has crashed, i see the expected env vars.

The fly.toml env vars are not automatically set in the machine as the spawned machines don't know anything about fly.toml at all. In such cases, you'll need to forward your own env from the parent in the pool options. If you want to send a PR to menetion this in the FlyBackend moduledoc, please do!. Thanks!