Peter Berg
Peter Berg

Reputation: 6206

Set Airflow Env Vars at Runtime

If I set env vars corresponding to airflow config settings after executing the airflow binary and at the same time DAG definitions are being loaded into memory, will this have the same effect as having set these same env vars at the OS level prior to having executed the binary?

Upvotes: 1

Views: 1881

Answers (1)

Peter Berg
Peter Berg

Reputation: 6206

I wasn't able to find any documentation on whether this would work as intended and figured that if I had to read through the source to figure this out then it's probably not a good idea to be doing it in the first place.

Instead of setting environment variables at runtime I've created two airflow.cfg files: airflow.prod.cfg and airflow.dev.cfg. I then created a shell script start.sh that cps the appropriate .cfg file to airflow.cfg prior to executing the airflow binary.

I don't love having to use the shell script to boot things up but I'd prefer that to chancing any kind of spooky action as a result of setting env vars at runtime.

Upvotes: 1

Related Questions