

More information in the gunicorn signal handling docs. If the application is not preloaded (using the preload_app option), Gunicorn will also load the new version of it. HUP: Reload the configuration, start the new worker processes with a new configuration and gracefully shutdown older workers. The HUP signal is sent to the master process, which performs these actions:
AIRFLOW SCHEDULER AUTO RESTART CODE
The scheduler will always use the latest code without need for a reboot. Gunicorn uses a preforking model, so it has master and worker processes. Airflow will restart itself automatically, and if you refresh the UI you. This file could be in $AIRFLOW_HOME or also /var/run, which is where you'll find a lot of pids.Īssuming the pid file is in /var/run, you could run the command: cat /var/run/airflow-webserver.pid | xargs kill -HUP You'll need to locate the pid file for the airflow webserver daemon in order to get the right process id to send the signal to. A signal commonly used by daemons to restart is HUP. Use Airflow webserver's (gunicorn) signal handlingĪirflow uses gunicorn as it's HTTP server, so you can send it standard POSIX-style signals. P.S: change AIRFLOW_HOME to where your airflow folder with the config Here is the tough part: I then run docker run -rm -tp 8080:8080 learning/airflow:latest webserver and in a separate terminal I run docker exec docker ps -q airflow scheduler. Wants=rvice rvice rvice rviceĮnvironmentFile=/home/airflow/airflow.envĮxecStart=/bin/bash -c 'export AIRFLOW_HOME=/home/airflow airflow webserver -pid /run/airflow/webserver.pid' Put it in /lib/systemd/system/rvice Īfter=network.target rvice rvice rvice rvice If you run it on a machine outside of the AWS ecosystem, you'd need to ensure it has access to AWS through credentials.I advice running airflow in a robust way, with auto-recovery with systemdįor this you'll need a systemd 'unit' file.Īs a (working) example you can use the following: Note that the EC2 instance on which my "docker-composed" Airflow app is running has an AWS role that allows her to create a log stream and add log events ( CreateLogStream and PutLogEvents actions in AWS IAM service). I just had to add the following to each service in the docker-compose.yml file ( ) : logging:
AIRFLOW SCHEDULER AUTO RESTART DRIVERS
The solution was to change the logging drivers so that logs are not stored on the Docker hosting instance anymore but sent directly to AWS CloudWatch Logs in my case.

The problem was in fact more at the Docker level, each one of those processes are responsible of tons of logs that are, by default, stored in json files by Docker. I spent a lot of time trying to add "maintenance" DAGs that would clear logs generated by the different airflow components started as Docker containers. ValueError: Unable to configure handler 'file.processor': Permission denied: '/usr/local/airflow/logs/scheduler/'Īnd so, how do people delete scheduler logs? ValueError: Unable to configure handler 'file.processor': Permission denied: '/usr/local/airflow/logs/scheduler' However, I get the following error in worker: Using deferrable operators as a DAG author is almost transparent writing them, however, takes a bit more work. The scheduler queues the task to resume on a worker node. The trigger is run until it fires, at which point its source task is re-scheduled. The first workaround is to disable autoscaling by freezing the number of worker in the cluster. You usually see incomplete logs when this happen. I have also setup remote logging, sending logs to S3, but as mentioned in this SO post Removing Airflow task logs this setup does not stop airflow from writing to the local machine.Īdditionally, I have also tried creating a shared named volume between the worker and the scheduler, as outlined here Docker Compose - Share named volume between multiple containers. The new Trigger instance is registered inside Airflow, and picked up by a triggerer process. If at that exact moment another task is schedule, then airflow will eventually run the task on a container being remove and your task will get killed in the middle without any notice (race condition). However, these tasks only delete logs on the worker, and the scheduler logs are in the scheduler container. I have all of these maintenance tasks set up: The scheduler produces a significant amount of logs, and the filesystem will quickly run out of space, so I am trying to programmatically delete the scheduler logs created by airflow, found in the scheduler container in (/usr/local/airflow/logs/scheduler)

I am using Docker Apache airflow VERSION 1.9.0-2 ( ).
