将气流调度程序作为守护进程运行的问题

Aar*_*ron 12 python amazon-ec2 airflow ubuntu-16.04 apache-airflow

我有一个运行气流1.8.0的EC2实例LocalExecutor.根据文档,我预计以下两个命令之一会以守护进程模式引发调度程序:

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
Run Code Online (Sandbox Code Playgroud)

第二个命令产生错误:

airflow scheduler: error: argument -D/--daemon: ignored explicit argument 'True'
Run Code Online (Sandbox Code Playgroud)

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

深入挖掘了我的StackOverflow帖子,其中一个响应建议systemd根据此repo可用的代码执行处理气流调度程序作为后台进程.

我对脚本的轻微修改后的修改将发布为以下Gists.我在Ubuntu 16.04.3上使用vanilla m4.xlarge EC2实例:

从那里我打电话给:

sudo systemctl enable airflow-scheduler
sudo systemctl start airflow-scheduler
Run Code Online (Sandbox Code Playgroud)

没有任何反应.虽然我在这个实例上运行了更复杂的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
Run Code Online (Sandbox Code Playgroud)

当我airflow scheduler手动运行时,一切正常.由于我的测试DAG的开始日期是9月9日,因此从那时起每分钟都要回填,产生一个运行时间自动收报机.systemd但是,当我使用调度程序作为守护程序时,它完全安静,没有明显的错误来源.

有什么想法吗?

Tag*_*gar 22

文档可能会过时?

我通常按​​照以下方式启动Airflow

airflow kerberos -D
airflow scheduler -D
airflow webserver -D
Run Code Online (Sandbox Code Playgroud)

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

-D, - damonmon 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 
Run Code Online (Sandbox Code Playgroud)

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

  • 很好的建议,但这并不能解决问题。当我在没有 daemonize 标志的情况下手动运行“airflow Scheduler”时,没有任何进程正在运行。这还能是什么?`which airflow` 产生这个:`/home/ubuntu/.local/bin/airflow` (2认同)