airflow - 如何在 systemd 中使用 Airflow 调度程序?
问题描述
文档指定了集成说明
我想要的是每次调度程序停止工作时,它都会由它自己重新启动。通常我手动启动它,airflow scheduler -D
但有时它会在我不可用时停止。
阅读文档我不确定配置。
GitHub包含以下文件:
airflow
airflow-scheduler.service
airflow.conf
我正在运行 Ubuntu 16.04
气流安装在:
home/ubuntu/airflow
我有以下路径:
etc/systemd
文档说:
将它们复制(或链接)到 /usr/lib/systemd/system
- 复制哪个文件?
将airflow.conf 复制到/etc/tmpfiles.d/
什么是 tmpfiles.d ?
# AIRFLOW_CONFIG=
气流文件中有什么?
或者换句话说……关于如何做的更“脚踏实地”的指南?
解决方案
Integrating Airflow with systemd files makes watching your daemons easy as systemd can take care of restarting a daemon on failure. This also enables to automatically start airflow webserver and scheduler on system start.
Edit the airflow
file from systemd
folder in Airflow Github as per the current configuration to set the environment variables for AIRFLOW_CONFIG
, AIRFLOW_HOME
& SCHEDULER
.
Copy the services files (the files with .service
extension) to /usr/lib/systemd/system
in the VM.
Copy the airflow.conf
file to /etc/tmpfiles.d/ or /usr/lib/tmpfiles.d/. Copying airflow.conf
ensures /run/airflow
is created with the right owner and permissions (0755 airflow airflow
). Check whether /run/airflow
exist with airflow:airflow
owned by airflow user and airflow group if it doesn't create /run/airflow
folder with those permissions.
Enable this services by issuing systemctl enable <service>
on command line as shown below.
sudo systemctl enable airflow-webserver
sudo systemctl enable airflow-scheduler
airflow-scheduler.service
file should be as below:
[Unit]
Description=Airflow scheduler daemon
After=network.target postgresql.service mysql.service redis.service rabbitmq-server.service
Wants=postgresql.service mysql.service redis.service rabbitmq-server.service
[Service]
EnvironmentFile=/etc/sysconfig/airflow
User=airflow
Group=airflow
Type=simple
ExecStart=/bin/airflow scheduler
Restart=always
RestartSec=5s
[Install]
WantedBy=multi-user.target
推荐阅读
- xamarin.forms - 如何在行为中获得另一个视图?
- c++ - 如何在mac上升级g++?
- r - 使用 While 循环在 R 中实现牛顿法
- c# - mdb vue 和 bootstrap vue 有什么区别?
- react-native - React Native Android - 生命周期方法
- python - Google 日历 API 全天活动时区
- linux - 使用绑定挂载的主机目录和容器之间的 Docker 文件权限不匹配
- amazon-cloudwatch - 为什么 fluentd-cloudwatch Kube deamonSet 无法将日志从指定目录发送到 cloudwatch?
- c - 为什么不满足if条件?
- c++ - "(void) cast" 与 "__attributes__" 用于消除未使用的参数警告之间的功能区别是什么?