airflow调度系统学习笔记一一DAG触发,重启

一、aiflow触发DAG有两种方式:

1、内部触发:

也就是通过设置参数 schedule_interval 来触发DAG,时间一到,DAG就会执行

2、外部传参触发:

import requests
import json

data={
    # "ipaddr":"10.0.6.165",
    # "user":"postgres",
    "lucyIp":"10.21.154.76",
    "execTime":"2h"
}

url="http://10.0.0.53:8082/api/experimental/dags/dag_id/dag_runs"
data_info={}
data_info["conf"]=data
data_info['execution_date'] = '2019/09/26 03:10:35'   #指定DAG执行时间


headers = {'Content-type': 'application/json'}
r = requests.post(url, data=json.dumps(data_info), auth=(user, password),headers=headers)
print(r.text)
print(data)

上面是通过web传参触发 ,设置的execution_date时间会指定DAG执行时间

参考链接:https://blog.csdn.net/YF_Li123/article/details/84075588 

3、注意:两种DAG触发方式不能共存

通过内部触发DAG,就不能用外部传参触发DAG ;用外部传参触发DAG就不能用内部触发DAG

二、服务重启 ,webserver重启一样

cat airflow-scheduler.pid   #查看pid
ps -ef | grep airflow       #kill掉相关pid
rm airflow-scheduler.pid    #先删除Pid文件
airflow scheduler -D        #后台重启               
airflow scheduler           #前台重启

发布了70 篇原创文章 · 获赞 11 · 访问量 3万+

猜你喜欢

转载自blog.csdn.net/YMY_mine/article/details/102522881