您好我正在使用Airflow并将我的气流项目放在EC2中。但是,当我的mac进入睡眠状态或退出ssh时,如何保持气流调度程序运行?
答案 0 :(得分:2)
您有几个选项,但没有一个可以在睡眠的笔记本电脑上保持活动状态。在服务器上: 可以使用--daemon作为守护进程运行:airflow scheduler --daemon 或者,也许在后台运行:气流调度程序>& log.txt& 或者,如上所述在'screen'内运行,然后使用ctrl-a d从屏幕上分离,根据需要使用'screen -r'重新连接。这将适用于ssh连接。
答案 1 :(得分:2)
我使用nohup
来保持调度程序的运行,并将输出重定向到日志文件,如下所示:
nohup airflow scheduler >> ${AIRFLOW_HOME}/logs/scheduler.log 2>&1 &
注意:假设您在EC2实例上运行调度程序,而不是在笔记本电脑上运行。
答案 2 :(得分:2)
如果您需要更多关于将其作为deamon运行的详细信息,即完全从终端分离并重定向stdout和stderr,这是一个示例:
airflow webserver -p 8080 -D --pid /your-path/airflow-webserver.pid --stdout /your-path/airflow-webserver.out --stderr /your-path/airflow-webserver.err
airflow scheduler -D --pid /your-path/airflow-scheduler.pid —stdout /your-path/airflow-scheduler.out --stderr /your-path/airflow-scheduler.err
答案 3 :(得分:0)
最强大的解决方案是将其注册为EC2实例上的服务。 Airflow为其提供了systemd和upstart脚本(https://github.com/apache/incubator-airflow/tree/master/scripts/systemd和https://github.com/apache/incubator-airflow/tree/master/scripts/upstart)。 对于Amazon Linux,您需要upstart脚本,例如Ubuntu,你会使用systemd脚本。
将其注册为系统服务更加强大,因为Airflow将在重新启动或崩溃时启动。当您使用例如,情况并非如此nohup就像其他人在这里建议的那样。