【发布时间】:2018-03-10 14:47:42
【问题描述】:
我有一个使用 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'
这很奇怪,因为根据docs --daemon=True 应该是airflow scheduler 调用的有效参数。
深入挖掘将我带到this StackOverflow post,其中一个回复建议根据this repo 提供的代码将气流调度程序作为后台进程处理systemd。
我对脚本的轻微编辑改编发布为以下要点。我正在使用带有 Ubuntu 16.04.3 的 vanilla m4.xlarge EC2 实例:
- /etc/sysconfig/airflow
- /user/lib/systemd/system/airflow-scheduler.service
- /etc/tmpfiles.d/airflow.conf
从那里我打电话:
sudo systemctl enable airflow-scheduler
sudo systemctl start airflow-scheduler
然后什么也没有发生。虽然我在此实例上运行了更复杂的 DAG,但 I am using this dummy case 创建了一个简单的测试,该测试还用作侦听器,让我知道调度程序何时按计划运行。
我一直在使用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 将调度程序作为守护进程运行时,它完全安静,没有明显的错误来源。
有什么想法吗?
【问题讨论】:
标签: python amazon-ec2 ubuntu-16.04 airflow apache-airflow