我的systemd单元文件正在运行(下方)。
然而,airflow-monitor.pid
文件暂时变为只读,这有时会阻止气流启动。我们的解决方法是在发生这种情况时删除airflow-monitor.pid。这与airflow.pid不是同一个文件。
看起来airflow.pid
是gunicorn而airflow-monitor.pid
是一个python进程,就像气流网络服务器一样。
systemd单元文件:
[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]
# by default we just set $AIRFLOW_HOME to its default dir: $HOME/airflow , so lets skip this for now
EnvironmentFile=/home/airflow/airflow/airflow.systemd.environment
#WorkingDirectory=/home/airflow/airflow-venv
#Environment=PATH="/home/airflow/airflow-venv/bin:$PATH"
PIDFile=/home/airflow/airflow/airflow.pid
User=airflow
Group=airflow
Type=simple
# this was originally the file webserver.pid but did not run
#ExecStart=/bin/bash -c 'source /home/airflow/airflow-venv/bin/activate ; /home/airflow/airflow-venv/bin/airflow webserver -p 8080 --pid /home/airflow/airflow/airflow.pid --daemon'
#ExecStart=/home/airflow/airflow-venv/bin/airflow webserver -p 8080 --pid /home/airflow/airflow/airflow.pid --daemon
ExecStart=/usr/local/bin/airflow webserver -p 8080 --pid /home/airflow/airflow/airflow.pid --daemon
Restart=on-failure
RestartSec=5s
PrivateTmp=true
[Install]
WantedBy=multi-user.target
以下是pid文件的输出:
airflow@airflow:~$ cat airflow/airflow.pid
8397
airflow@airflow:~$ cat airflow/airflow-monitor.pid
8377
airflow@airflow:~$ ps faux | grep 8377
airflow 26004 0.0 0.0 14224 976 pts/0 S+ 18:05 0:00 | \_ grep --color=auto 8377 airflow 8377 0.4 1.0 399676 83804 ? Ss Aug23 6:14 /usr/bin/python /usr/local/bin/airflow webserver -p 8080 --pid /home/airflow/airflow/airflow.pid --daemon
airflow@airflow:~$ ps faux | grep 8397
airflow 26028 0.0 0.0 14224 940 pts/0 R+ 18:05 0:00 | \_ grep --color=auto 8397 airflow 8397 0.0 0.6 186652 55496 ? S Aug23 0:32 gunicorn: master [airflow-webserver]
答案 0 :(得分:4)
不完全确定为什么airflow-monitor.pid
变为只读,但您可以通过不使用--daemon
运行网络服务器来完全避免此pid文件。我不认为systemd是必要的。
相关的代码块:https://github.com/apache/incubator-airflow/blob/master/airflow/bin/cli.py#L754-L765