我试图使用systemd在Ubuntu16.04文件上运行apache-airflow。我大致遵循了本教程并安装/设置了以下内容:
sudo apt-get install gcc)yml文件在以下conda环境中:
当我测试气流时,一切都很好:
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守护进程时,status返回以下错误:
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'.我们非常感谢你的帮助!
发布于 2018-09-13 09:20:22
下面是适用于我的虚拟环境的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发布于 2018-09-19 07:58:24
对于我来说,有一个完全不同但却容易得多的解决方案:
airflowapache-airflow用户的身份在环境中安装airflowairflow webserver --port 8080 -D运行气流守护进程这会以后台进程的形式运行气流。您只需切换回其他用户并继续创建dags,等等。
发布于 2020-03-28 05:49:42
由kaxil给出的回答有点为我工作!但只要稍加修改。
我安装了我的气流(使用Anaconda),并位于:
#-> whereis airflow
airflow: /root/anaconda3/bin/airflow在airflow-webserver.service文件中添加下面一行为我解决了这个问题。
ExecStart=/usr/bin/bash -c 'source /root/anaconda3/bin/activate ; airflow webserver --pid /run/airflow/webserver.pid'在它说了Error: /run/airflow doesn't exist. Can't create pidfile.之后,我发现了另一个错误,在[Service]下添加了下面的内容也解决了这个问题
RuntimeDirectory=airflow
RuntimeDirectoryMode=0775https://stackoverflow.com/questions/52310217
复制相似问题