diff --git a/airflow/cli/commands/daemon_utils.py b/airflow/cli/commands/daemon_utils.py index fce0b1d50001f..d3af46dc056a6 100644 --- a/airflow/cli/commands/daemon_utils.py +++ b/airflow/cli/commands/daemon_utils.py @@ -48,11 +48,10 @@ def run_command_with_daemon_option( If not specified, a file path is generated with the default pattern. """ if args.daemon: + pid = pid_file or args.pid if pid_file is not None or args.pid is not None else None pid, stdout, stderr, log_file = setup_locations( - process=process_name, stdout=args.stdout, stderr=args.stderr, log=args.log_file + process=process_name, pid=pid, stdout=args.stdout, stderr=args.stderr, log=args.log_file ) - if pid_file: - pid = pid_file # Check if the process is already running; if not but a pidfile exists, clean it up check_if_pidfile_process_is_running(pid_file=pid, process_name=process_name) diff --git a/tests/cli/commands/test_celery_command.py b/tests/cli/commands/test_celery_command.py index 503c488482fac..1659588237755 100644 --- a/tests/cli/commands/test_celery_command.py +++ b/tests/cli/commands/test_celery_command.py @@ -340,6 +340,7 @@ def test_run_command_daemon(self, mock_celery_app, mock_daemon, mock_setup_locat assert mock_setup_locations.mock_calls == [ mock.call( process="flower", + pid="/tmp/flower.pid", stdout="/tmp/flower-stdout.log", stderr="/tmp/flower-stderr.log", log="/tmp/flower.log", diff --git a/tests/cli/commands/test_kerberos_command.py b/tests/cli/commands/test_kerberos_command.py index 2c23ac608310c..f5c9823f52a0c 100644 --- a/tests/cli/commands/test_kerberos_command.py +++ b/tests/cli/commands/test_kerberos_command.py @@ -93,6 +93,7 @@ def test_run_command_daemon(self, mock_krb, mock_daemon, mock_setup_locations, m assert mock_setup_locations.mock_calls[0] == mock.call( process="kerberos", + pid="/tmp/kerberos.pid", stdout="/tmp/kerberos-stdout.log", stderr="/tmp/kerberos-stderr.log", log="/tmp/kerberos.log",