问题描述
我正在尝试使用systemd在Ubuntu 16.04文件上运行 apache-airflow
。我大致遵循了,并安装/设置了以下内容:
I'm trying to run apache-airflow
on a Ubuntu 16.04 file, using systemd. I roughly followed this tutorial and installed/setup the following:
- Miniconda 2,64位
- 已安装gcc(
sudo apt-get install gcc
) - Conda环境,使用教程的
yml
文件
- Miniconda 2, 64-bit
- Installed gcc (
sudo apt-get install gcc
) - Conda environment, using the
yml
file of the tutorial
在以下conda环境中:
Within the following conda environment:
- export AIRFLOW_HOME = / home / ubuntu / airflow
当我测试气流时,一切正常:
When I test Airflow, everything works fine:
airflow webserver --port 8080
但是每当我尝试使用systemd文件,它失败。据我所知,systemd文件利用了conda环境。我的systemd文件如下所示:
But whenever I try to launch airflow using a systemd file, it fails. The systemd file makes use of the conda environment, as far as I understand correctly. My systemd file looks as follows:
[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守护程序时,状态返回以下错误:
When I start/enable the systemd daemon, status returns the following error:
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'.
我们非常感谢您的帮助!
Help is highly appreciated!
推荐答案
以下是 airflow-webserver.service
,它在虚拟环境中适用于我:
The following is airflow-webserver.service
that works for me with a virtual environment:
[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
这篇关于使用conda env的apache-airflow systemd文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!