单机的airflow scheduler很容易挂掉,出现服务故障,所以使用supervisor监控进程,实现服务故障发生时,自动重启服务。
Supervisor安装
1 使用pip安装
安装supervisor
安装后的执行文件会默认安装在pip的执行文件目录。
进入这个目录,会看到新生成的三个文件,
2 生成配置文件
./echo_supervisord_conf > supervisored.conf
设置配置文件
mkdir -p /etc/supervisor/conf.d
cp supervisored.conf /etc/supervisor/
3 修改配置文件
修改此配置文件/etc/supervisor/supervisored.conf
4 创建socket空文件
以后的进程配置文件都要放在这个文件夹
touch /tmp/supervisor.sock
5 airflow监控配置文件
[program:airflow]
command=airflow scheduler ; 被监控的进程路径
priority=1 ; 数字越高,优先级越高
numprocs=1 ; 启动几个进程
autostart=true ; 随着supervisord的启动而启动
autorestart=true ; 自动重启
startretries=10 ; 启动失败时的最多重试次数
exitcodes=0 ; 正常退出代码
stopsignal=KILL ; 用来杀死进程的信号
stopwaitsecs=10 ; 发送SIGKILL前的等待时间
redirect_stderr=true ; 重定向stderr到stdout
6 启动supervisor
./supervisord -c /etc/supervisor/supervisored.conf