将运行气流调度程序作为守护程序过程发出问题



我有一个使用LocalExecutor运行气流1.8.0的EC2实例。根据文档,我本来可以预期以下两个命令之一会在守护程序模式下提高调度程序:

airflow scheduler --daemon --num_runs=20

airflow scheduler --daemon=True --num_runs=5

但事实并非如此。第一个命令似乎可以正常工作,但是它只是在返回终端之前返回以下输出而无需产生任何背景任务:

[2017-09-28 18:15:02,794] {__init__.py:57} INFO - Using executor LocalExecutor
[2017-09-28 18:15:03,064] {driver.py:120} INFO - Generating grammar tables from /usr/lib/python3.5/lib2to3/Grammar.txt
[2017-09-28 18:15:03,203] {driver.py:120} INFO - Generating grammar tables from /usr/lib/python3.5/lib2to3/PatternGrammar.txt

第二个命令产生错误:

airflow scheduler: error: argument -D/--daemon: ignored explicit argument 'True'

这很奇怪,因为根据文档,--daemon=True应该是airflow scheduler调用的有效参数。

更深入地挖掘我的stackoverflow帖子,其中一个响应建议根据可用的代码作为背景过程来实现systemd,以将气流调度程序作为背景过程作为背景过程。

我对脚本的轻微编辑的改编被发布为以下要点。我正在使用ubuntu 16.04.3:

使用香草M4.xlarge EC2实例
  • /etc/sysconfig/airffig
  • /user/lib/systemd/system/airflow-scheduler.service
  • /etc/tmpfiles.d/airflow.conf

从那里我打电话:

sudo systemctl enable airflow-scheduler
sudo systemctl start airflow-scheduler

,什么也没发生。虽然我在此实例上运行得更复杂的DAG,但我正在使用此虚拟案例来创建一个简单的测试,该测试也可以用作听众,让我知道调度程序何时按计划运行。

我一直在使用journalctl -f进行调试。以下是调度程序过程中的几行输出行。没有明显的问题,但是我的任务没有执行,也没有为测试DAG生成日志,这可以帮助我放大错误。问题在这里吗?

Sep 28 18:39:30 ip-172-31-15-209 airflow[20603]: [2017-09-28 18:39:30,965] {dag_processing.py:627} INFO - Started a process (PID: 21822) to generate tasks for /home/ubuntu/airflow/dags/scheduler_test_dag.py - logging into /home/ubuntu/airflow/logs/scheduler/2017-09-28/scheduler_test_dag.py.log
Sep 28 18:39:31 ip-172-31-15-209 airflow[20603]: [2017-09-28 18:39:31,016] {jobs.py:1002} INFO - No tasks to send to the executor
Sep 28 18:39:31 ip-172-31-15-209 airflow[20603]: [2017-09-28 18:39:31,020] {jobs.py:1440} INFO - Heartbeating the executor
Sep 28 18:39:32 ip-172-31-15-209 airflow[20603]: [2017-09-28 18:39:32,022] {jobs.py:1404} INFO - Heartbeating the process manager
Sep 28 18:39:32 ip-172-31-15-209 airflow[20603]: [2017-09-28 18:39:32,023] {jobs.py:1440} INFO - Heartbeating the executor
Sep 28 18:39:33 ip-172-31-15-209 airflow[20603]: [2017-09-28 18:39:33,024] {jobs.py:1404} INFO - Heartbeating the process manager
Sep 28 18:39:33 ip-172-31-15-209 airflow[20603]: [2017-09-28 18:39:33,025] {dag_processing.py:559} INFO - Processor for /home/ubuntu/airflow/dags/capone_dash_dag.py finished
Sep 28 18:39:33 ip-172-31-15-209 airflow[20603]: [2017-09-28 18:39:33,026] {dag_processing.py:559} INFO - Processor for /home/ubuntu/airflow/dags/scheduler_test_dag.py finished

当我手动运行airflow scheduler时,这一切都很好。由于我的测试DAG的开始日期为9月9日,因此从那时起,每分钟就一直在回填,从而产生了运行时间。但是,当我使用systemd将调度程序作为Deamon运行时,它完全安静,没有明显的错误来源。

有什么想法吗?

文档可以日期?

我通常按以下

开始气流
airflow kerberos -D
airflow scheduler -D
airflow webserver -D

这是airflow webeserver --help输出(从版本1.8):

-d, - daemon daemonize而不是在前景中运行

请注意,那里没有布尔标志。文档必须修复。

快速注意,如果airflow scheduler -D失败:

这包含在评论中,但似乎值得一提。运行气流调度程序时,它将创建文件$AIRFLOW_HOME/airflow-scheduler.pid。如果您尝试重新运行气流调度程序守护程序进程,则几乎可以肯定会产生文件$AIRFLOW_HOME/airflow-scheduler.err,该文件将告诉您lockfile.AlreadyLocked: /home/ubuntu/airflow/airflow-scheduler.pid is already locked。如果您的调度程序守护程序确实是不成熟的,并且您发现自己需要重新启动是执行以下命令:

sudo rm $AIRFLOW_HOME airflow-scheduler.err  airflow-scheduler.pid
airflow scheduler -D 

这使我的调度程序重回正轨。

关于任务通过SystemD启动:

我对路径变量的问题有问题,而这种方式最初是空的。也就是说,当您写入文件/etc/sysconfig/airflow时:

PATH=/home/ubuntu/bin:/home/ubuntu/.local/bin:$PATH

您从字面上写:

PATH=/home/ubuntu/bin:/home/ubuntu/.local/bin

因此,变量PATH不包含/bin,这是LocaleXecutor来运行任务的bash实用程序。

所以我不明白为什么在此文件中您尚未指定AIRFLOW_HOME。也就是说,气流正在寻找其配置文件的目录。

最新更新