环境变量中的气流配置不起作用 [英] Airflow configuration in environment variable not working
问题描述
我尝试使用ENV变量配置连接url,我的ami已预先配置有alchemy_conn和broker_url等,在从amis旋转的实例中,我已经将环境变量写入了/etc/environment中以覆盖其中的属性.airflow.cfg文件.我也能够从python代码访问变量.
I tried using ENV variable to configure connection urls, I have an ami that is preconfigured with alchemy_conn and broker_url etc, I have written environment variables to /etc/environment in the instances being spun up from the amis to override the properties in airflow.cfg file. I was able to access the variables from python code as well.
但是它在运行ariflow时似乎没有生效,也尝试过重新启动该过程但没有用,它仍然指向airflow.cfg文件中的那个
But it doesn't seem to take effect while running ariflow, tried restarting the process as well but didn't work, it still points to the one in airflow.cfg file
推荐答案
问题可能是系统服务不会自动从/etc/environment
中获取仅用于交互式会话的环境.
The issue is probably that system services do not automatically pick up environment from /etc/environment
that is just for interactive sessions.
如果使用systemd,则可以添加 EnvironmentFile =/etc/environment
,尽管更典型"的做法是将服务特定的配置放在/etc/default/airflow
(在Debian/Ubuntu上)或/etc/sysconfig/airflow
(在Centos/Redhat上)
If you are using systemd you can add EnvironmentFile=/etc/environment
, though more "typical" would be to put the service specific config in /etc/default/airflow
(on Debian/Ubuntu) or /etc/sysconfig/airflow
(on Centos/Redhat)
来自Airflow的示例systemd脚本已针对Centos使用: https://github.com/apache/incubator-airflow/blob/faa9a5266c0b2e68693dd106b5cb46d30770dadc/scripts/systemd/airflow-webserver.service#L20
The example systemd scripts from Airflow already have this for Centos: https://github.com/apache/incubator-airflow/blob/faa9a5266c0b2e68693dd106b5cb46d30770dadc/scripts/systemd/airflow-webserver.service#L20
这篇关于环境变量中的气流配置不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!