Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Logging with Gunicorn and use_queues #89

Closed
GrahamMThomas opened this issue Mar 11, 2020 · 8 comments
Closed

Logging with Gunicorn and use_queues #89

GrahamMThomas opened this issue Mar 11, 2020 · 8 comments

Comments

@GrahamMThomas
Copy link

GrahamMThomas commented Mar 11, 2020

Not sure if this is a bug in a package. I'm just writing this to help the next poor soul who comes along and tries to get this to work.

Maybe it's obvious to others, use_queues has to spawn a thread to manage a queue. Gunicorn spawns threads to handle api requests. The use_queues thread is unable to listen to the Gunicorn threads... I think...

Therefore use_queues must be disabled in order to get access logs from gunicorn.

coderbydesign added a commit to coderbydesign/insights-rbac that referenced this issue Apr 3, 2020
There's currently an issue where logs in the gunicorn app server process don't
get pushed to CW. This resolves that, in order to make way for formatting RBAC
logs as JSON.

Here are some related issues which presented the solution:

kislyuk/watchtower#54
kislyuk/watchtower#89
@jasondarnell
Copy link

I am the "next poor soul". Thank you for noting this.

@ibuys
Copy link

ibuys commented Jul 1, 2020

Possibly related, I ran into an issue today during deployment of a Django application that relies on Gunicorn, using watchtower==0.8.0 caused Gunicorn to crash on launch, downgrading to watchtower==0.7.3 and the problem went away and Gunicorn started normally.

@colinhowe
Copy link

colinhowe commented Sep 10, 2020

This just saved my bacon too. For future searchers: .../watchtower/__init__.py:200: WatchtowerWarning: Received message after logging system shutdown is the error that pops up.

Would be good to not have to turn off queues

Edit to add: I switched my logging from being configured in gunicorn to being configured in Django and it worked. I had to coax gunicorn into not skipping access logging with this travesty: logconfig_dict = {'dummyvalue': True}

@luisjimenez6245
Copy link

Im running to WatchtowerWarning: Received message after logging system shutdown when running the watchtower with FastAPI, The solutions was to disable queues. but is there a way to fix this issue?

@kislyuk
Copy link
Owner

kislyuk commented Dec 10, 2021

I am unable to reproduce this issue. When I run my wsgi application with gunicorn, I am able to log messages successfully. It's possible that logging messages in certain contexts causes a deadlock, but I would need specific information on how to reproduce that in order to act on it.

Setting use_queues to False in production is not recommended, since it will cause performance issues due to the synchronous sending of one CloudWatch API request per log message.

@kislyuk kislyuk closed this as completed Dec 10, 2021
@DilLip-Chowdary-Codes
Copy link

Setting use_queues to False in production is not recommended, since it will cause performance issues due to the synchronous sending of one CloudWatch API request per log message.

Got the same issue, any solutions for this?

@Insighttful
Copy link

Same issue. Using Uvicorn 0.24 and FastAPI 0.105.

@bluemarbleconsulting
Copy link

Also seeing this issue with FastAPI 0.115.6 and uvicorn 0.34.0. FastAPI starts, the WatchtowerWarning is thrown, and then it seems the thread dies entirely causing any future logs to not be sent.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants