I had the same error in a Django application. When the server starts, it seems to work well, but the message [INFO] ASGI 'lifespan' protocol appears unsupported
appears.
(authentication-py3.11) ml@192 authentication % python -m gunicorn "authentication.asgi:application"
[2023-04-12 10:07:28 -0300] [2900] [INFO] Starting gunicorn 20.1.0
[2023-04-12 10:07:28 -0300] [2900] [INFO] Listening at: http://0.0.0.0:8000 (2900)
[2023-04-12 10:07:28 -0300] [2900] [INFO] Using worker: uvicorn.workers.UvicornWorker
[2023-04-12 10:07:28 -0300] [2902] [INFO] Booting worker with pid: 2902
[2023-04-12 13:07:29 +0000] [2902] [INFO] Started server process [2902]
[2023-04-12 13:07:29 +0000] [2902] [INFO] Waiting for application startup.
[2023-04-12 13:07:29 +0000] [2902] [INFO] ASGI 'lifespan' protocol appears unsupported.
[2023-04-12 13:07:29 +0000] [2902] [INFO] Application startup complete.
Following a solution in this issue, I created a custom uvicorn worker disabling the lifespan protocol.
workers.py
from typing import Any, Dict
from uvicorn.workers import UvicornWorker as BaseUvicornWorker
class UvicornWorker(BaseUvicornWorker):
CONFIG_KWARGS: Dict[str, Any] = {"loop": "auto", "http": "auto", "lifespan": "off"}
gunicorn.conf.py
from myapp import settings
port = int(settings.APPLICATION_PORT)
bind = f"0.0.0.0:{port}"
workers = int(settings.GUNICORN_WORKERS)
worker_class = "myapp.workers.UvicornWorker"
accesslog = "-"