Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Refreshing dags without web server restart apache airflow

Tags:

airflow

Is there any way to reload the jobs without having to restart the server?

like image 686
ryudice Avatar asked Apr 25 '17 09:04

ryudice


People also ask

How do I restart my scheduler Airflow?

You can do start/stop/restart actions on an Airflow service and the commands used for each service are given below: Run sudo monit <action> scheduler for Airflow Scheduler. Run sudo monit <action> webserver for Airflow Webserver.

How do I turn off Airflow on web server?

If you run Airflow locally and start it with the two commands airflow scheduler and airflow webserver , then those processes will run in the foreground. So, simply hitting Ctrl-C for each of them should terminate them and all their child processes.


3 Answers

In your airflow.cfg, you've these two configurations to control this behavior:

# after how much time a new DAGs should be picked up from the filesystem
min_file_process_interval = 0
dag_dir_list_interval = 60

You might have to reload the web-server, scheduler and workers for your new configuration to take effect.

like image 162
x97Core Avatar answered Oct 17 '22 11:10

x97Core


I had the same question, and didn't see this answer yet. I was able to do it from the command line with the following:

python -c "from airflow.models import DagBag; d = DagBag();"

When the webserver is running, it refreshes dags every 30 seconds or so by default, but this will refresh them in between if necessary.

like image 26
theis188 Avatar answered Oct 17 '22 11:10

theis188


Dags should be reloaded when you update the associated python file.

If they are not, first try to manually refresh them in UI by clicking the button that looks like a recycle symbol:

airflow ui refresh button

If that doesn't work, delete all the .pyc files in the dags folder.

Usually though, when I save the python file the dag gets updated within a few moments.

like image 15
jhnclvr Avatar answered Oct 17 '22 10:10

jhnclvr