Airflow upstart 脚本在 start/running 状态后立即进入 stop/waiting 状态

Airflow upstart script enters stop/waiting state immediately after start/running state

我正在尝试 运行 来自 airflow 官方回购的新贵脚本:https://github.com/apache/incubator-airflow/blob/master/scripts/upstart/airflow-webserver.conf

start on started networking
stop on (deconfiguring-networking or runlevel [016])

respawn
respawn limit 5 30

setuid airflow
setgid airflow

exec usr/local/bin/airflow webserver

当我 运行 这是输出:

$ sudo service airflow-webserver start
airflow-webserver start/running, process 7612

$ sudo service airflow-webserver status
airflow-webserver stop/waiting

但是仅仅做exec /usr/local/bin/airflow webserver就可以运行完美无缺地完成,这令人费解。有谁知道为什么会这样?


* 您可以通过 pip install airflow 获得气流进行测试,以防您需要自己查看。

Upstart 在干净的环境中运行,这意味着它不会使用 /etc/environment 中的变量。这意味着您必须再次设置 AIRFLOW_HOMEAIRFLOW_CONFIG

description "Airflow webserver daemon"

start on started networking
stop on (deconfiguring-networking or runlevel [016])

respawn
respawn limit 5 30

setuid airflow
setgid airflow

# I omitted all of the below because I assumed 
# it would pick it up from the already defined env
env AIRFLOW_CONFIG=/path/to/airflow/airflow.cfg
env AIRFLOW_HOME=/path/to/airflow
export AIRFLOW_CONFIG
export AIRFLOW_HOME

exec usr/local/bin/airflow webserver

这是我在 Ubuntu 16 中所做的: (初始化脚本取自 incubator-airflow git repo)

$ sudo cp incubator-airflow/scripts/systemd/*.service /etc/systemd/system/

在每个服务文件中,将用户和组行更改为所有者 目录,在我的例子中 - ubuntu 并修改 ExecStart:

User=ubuntu

Group=ubuntu

ExecStart=/usr/local/bin/airflow  webserver --pid $AIRFLOW_HOME/webserver.pid

请记住,ExecStart 行在每个服务行中都是不同的。

然后:

$ sudo cp incubator-airflow/scripts/systemd/*.conf /etc/tmpfiles.d/
$ sudo mkdir /etc/sysconfig
$ sudo cp incubator-airflow/scripts/systemd/airflow /etc/sysconfig/airflow

将以下行添加到 /etc/sysconfig/airflow:

AIRFLOW_CONFIG=YOUR_airflow_home/airflow.cfg

AIRFLOW_HOME=YOUR_airflow_home

最后:

sudo systemctl daemon-reload
sudo systemctl start airflow-webserver

(或任何其他气流服务)

祝你好运!