UserWarning Logging continues every 1 to 3 minutes.

Logging continues every 1 to 3 minutes.

"/usr/local/lib/python3.7/site-packages/sanic/ UserWarning: You have set a listener for "before_server_start" in ASGI mode. It will be executed as early as possible, but not before the ASGI server is started."

Is the server restarting?

If there is a way to apply when using uvicorn, I would like to get help.

Hi @devappkr, thanks for the post.

When you are running in ASGI mode, you are using Sanic just as a framework tool for handling routing, Middleware, listeners, etc. You need to bring your own server (uvicorn, hypercorn, or Daphne).

Therefore, anything related to Sanic’s server is not applicable.

I’m curious: what is the motivation for using create_server? Or, for using ASGI?

Start using unicorn as below.
uvicorn server:app --workers=8 --host --port=8080 --log-level=warning

Yes, that is correct. Is this a response to my questions?

If so, you can skip that example and look at instead. Build your app however you would like. Just point uvicorn to the location of the module with your Sanic() instance.

uvicorn server:app
Sanic instance name is app (in the )
already using unicorn.

‘UserWarning’ Logging continues every 1 to 3 minutes.
I don’t know what the problem is.
Is the server still restarting?

Okay, so I may have completely misread your original question. I edited it to make it easier to read. Sorry about that.

First, you can get rid of the warning by using after_server_start instead of before_server_start.

Second, if you see that again and again, then yes, that means uvicorn is restarting.

A couple things spring to mind:

  1. You are in development mode, and when you save the files it triggers a restart. It does not look like you are using that though. In uvicorn, this is the --reload flag.
  2. Something in the app is causing the processes to crash. Is there any other logging?

What versions of Python/Sanic/uvicorn are you using?