python - 使用 conda env 的 apache-airflow systemd 文件
问题描述
我正在尝试apache-airflow
使用 systemd 在 Ubuntu 16.04 文件上运行。我大致按照本教程安装/设置了以下内容:
- Miniconda 2, 64 位
- 安装 gcc (
sudo apt-get install gcc
) - conda环境,使用
yml
教程的文件
在以下 conda 环境中:
- 出口 AIRFLOW_HOME="/home/ubuntu/airflow"
当我测试气流时,一切正常:
airflow webserver --port 8080
但是每当我尝试使用 systemd 文件启动气流时,它都会失败。据我正确理解,systemd 文件使用了 conda 环境。我的 systemd 文件如下所示:
[Unit]
Description=Airflow webserver daemon
[Service]
User=ubuntu
Group=ubuntu
Type=simple
ExecStart=/home/ubuntu/miniconda2/envs/airflow-tutorial/bin/airflow webserver --port 8080
Restart=on-failure
RestartSec=5s
PrivateTmp=true
[Install]
WantedBy=multi-user.target
当我启动/启用 systemd 守护程序时,状态返回以下错误:
airflow-webserver.service - Airflow webserver daemon
Loaded: loaded (/etc/systemd/system/airflow-webserver.service; enabled; vendor preset: enabled)
Active: activating (auto-restart) (Result: exit-code) since Thu 2018-09-13 08:59:00 UTC; 1s ago
Process: 18410 ExecStart=/home/ubuntu/miniconda2/envs/airflow-tutorial/bin/airflow webserver --port 8080 (code=exited, status=1/FAILURE)
Main PID: 18410 (code=exited, status=1/FAILURE)
Sep 13 08:59:00 ip-172-31-46-255 systemd[1]: airflow-webserver.service: Main process exited, code=exited, status=1/FAILURE
Sep 13 08:59:00 ip-172-31-46-255 systemd[1]: airflow-webserver.service: Unit entered failed state.
Sep 13 08:59:00 ip-172-31-46-255 systemd[1]: airflow-webserver.service: Failed with result 'exit-code'.
高度赞赏帮助!
解决方案
以下是airflow-webserver.service
适用于我的虚拟环境:
[Unit]
Description=Airflow webserver daemon
After=network.target postgresql.service mysql.service redis.service rabbitmq-server.service
Wants=postgresql.service mysql.service redis.service rabbitmq-server.service
[Service]
PIDFile=/run/airflow/webserver.pid
EnvironmentFile=/etc/default/airflow
User=airflow
Group=airflow
Type=simple
ExecStart=/usr/bin/bash -c 'source /usr/local/airflow/venv/bin/activate ; airflow webserver --pid /run/airflow/webserver.pid'
Restart=on-failure
RestartSec=5s
PrivateTmp=true
[Install]
WantedBy=multi-user.target
推荐阅读
- android - 使用片段事务替换特定片段
- spring-data-jpa - 我们什么时候需要在 Spring jpa 中使用锁定?
- pyspark - SparkSubmit can run locally?
- service-worker - 如何优雅地处理 PWA - Service Worker End-Of-Life
- google-chrome-extension - 谷歌 chrome 开发者登录 5 US 费用不起作用
- inno-setup - 通过 Inno Setup Compiler 脚本启用 NTFS 长路径
- azure - Azure AD B2C - 仅使用本地帐户登录时出现无效的用户名或密码错误
- python - 如何仅针对某些参数模拟对象/方法
- tensorflow - 如何修复:不预测本地存储在时尚 mnist 张量流样本中的图像
- c++ - 如何实现通用开关/案例,它也适用于一般 C++ 类型并且在语法上相似?