在运行时设置气流环境变量 [英] Set Airflow Env Vars at Runtime

查看:94
本文介绍了在运行时设置气流环境变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我在执行 airflow 二进制文件后设置了与airflow配置设置相对应的env vars,同时将DAG定义加载到内存中,这会产生相同的效果在执行二进制文件之前在操作系统级别设置了这些相同的环境变量?

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?

推荐答案

我找不到任何有关此操作是否能按预期工作的文档,都认为如果我必须通读源代码以解决问题,那么首先这样做可能不是一个好主意。

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.

我创建了两个 airflow.cfg 文件,而不是在运行时设置环境变量: airflow.prod.cfg airflow.dev.cfg 。然后,我创建了一个外壳脚本 start.sh ,其中 cp 是相应的 .cfg airflow 二进制文件之前,先将code>文件保存到 airflow.cfg

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.

我不喜欢使用shell脚本来启动程序,但是我宁愿选择设置env vars来选择任何怪异的动作在运行时。

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.

这篇关于在运行时设置气流环境变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆