jason810496 commented on code in PR #52860:
URL: https://github.com/apache/airflow/pull/52860#discussion_r2185721521


##########
airflow-core/src/airflow/cli/commands/api_server_command.py:
##########
@@ -40,6 +40,40 @@
 # more info here: 
https://github.com/benoitc/gunicorn/issues/1877#issuecomment-1911136399
 
 
+def _run_api_server(
+    args, apps: str, access_logfile: str, num_workers: int, worker_timeout: 
int, proxy_headers: bool
+):
+    """Run the API server."""
+    log.info(
+        textwrap.dedent(
+            f"""\
+            Running the uvicorn with:
+            Apps: {apps}
+            Workers: {num_workers}
+            Host: {args.host}:{args.port}
+            Timeout: {worker_timeout}
+            Logfiles: {access_logfile}
+            
================================================================="""
+        )
+    )
+    # get ssl cert and key filepaths here instead of passing them as arguments 
to reduce the number of arguments
+    ssl_cert, ssl_key = _get_ssl_cert_and_key_filepaths(args)
+
+    setproctitle(f"airflow api_server -- host:{args.host} port:{args.port}")
+    uvicorn.run(
+        "airflow.api_fastapi.main:app",
+        host=args.host,
+        port=args.port,
+        workers=num_workers,
+        timeout_keep_alive=worker_timeout,
+        timeout_graceful_shutdown=worker_timeout,
+        ssl_keyfile=ssl_key,
+        ssl_certfile=ssl_cert,
+        access_log=access_logfile,  # type: ignore[arg-type]

Review Comment:
   After tracing the history of Airflow 2 and gunicorn:
   - **gunicorn**
     - `--access-logfile`: The Access log file to write to and `-` means 
`stdout`
     - 
https://github.com/benoitc/gunicorn/blob/a86ea1e4e6c271d1cd1823c7e14490123f9238fe/docs/source/settings.rst#accesslog
   - **uvicorn**
     - `--log-config`: Logging configuration file that is valid for 
`logging.config.fileConfig`
     - https://www.uvicorn.org/settings/#production
   
   The `--access-logfile` option for `api_server_command` is inherited from 
Airflow 2 ( we were still using `gunicorn`  then ).
   
   To sum up, maybe we can deprecate the `access-logfile` config  ( since it's 
legacy stuff of `gunicorn`, we are not using anymore ) and add the `log-config` 
(  for `uvicorn` now ) and default as `None`?  This remain current behavior of 
api-server and provide the flexibility for user to set to logging related 
config for `uvicorn`.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@airflow.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to