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

fix bug 1525614: use mozlog for gunicorn #4822

Merged
merged 1 commit into from Feb 11, 2019
Merged

fix bug 1525614: use mozlog for gunicorn #4822

merged 1 commit into from Feb 11, 2019

Conversation

willkg
Copy link
Collaborator

@willkg willkg commented Feb 11, 2019

This sets gunicorn up with a config file to configure logging. It uses
existing webapp environment variables and mimics the way the webapp sets
up logging so that a local dev environment gets the console and server
environments get mozlog.

This sets gunicorn up with a config file to configure logging. It uses
existing webapp environment variables and mimics the way the webapp sets
up logging so that a local dev environment gets the console and server
environments get mozlog.
@willkg
Copy link
Collaborator Author

willkg commented Feb 11, 2019

This works locally when doing "make run" just fine. That covers the "local dev environment" mode.

The "server" mode is a little harder to trigger. We have to do something like this:

$ docker-compose run --service-ports webapp shell
app@de9fded47e40:/app$ cd webapp-django/
app@de9fded47e40:/app/webapp-django$ ./manage.py collectstatic
...
app@de9fded47e40:/app/webapp-django$ cd ..
app@de9fded47e40:/app$ LOCAL_DEV_ENV= ./docker/run_webapp.sh 

Then both the webapp and gunicorn will log in mozlog format and you'll see stuff like this:

{"Timestamp": 1549907106113734400, "Type": "gunicorn.error", "Logger": "socorro", "Hostname": "de9fded47e40", "EnvVersion": "2.0", "Severity": 6, "Pid": 601, "Fields": {"host_id": "de9fded47e40", "msg": "Booting worker with pid: 601"}}
{"Timestamp": 1549907115202945536, "Type": "gunicorn.access", "Logger": "socorro", "Hostname": "de9fded47e40", "EnvVersion": "2.0", "Severity": 6, "Pid": 601, "Fields": {"host_id": "de9fded47e40", "msg": "172.18.0.1 - - [11/Feb/2019:17:45:15 +0000] \"GET / HTTP/1.1\" 200 6990 \"-\" \"Mozilla/5.0 (X11; Linux x86_64; rv:67.0) Gecko/20100101 Firefox/67.0\""}}
{"Timestamp": 1549907115305317888, "Type": "gunicorn.access", "Logger": "socorro", "Hostname": "de9fded47e40", "EnvVersion": "2.0", "Severity": 6, "Pid": 601, "Fields": {"host_id": "de9fded47e40", "msg": "172.18.0.1 - - [11/Feb/2019:17:45:15 +0000] \"GET /static/jquery/dist/jquery.js HTTP/1.1\" 304 0 \"http://localhost:8000/\" \"Mozilla/5.0 (X11; Linux x86_64; rv:67.0) Gecko/20100101 Firefox/67.0\""}}

I'm going to land this and verify it works on stage. self-r+

@willkg willkg merged commit 44a1a17 into mozilla-services:master Feb 11, 2019
@willkg willkg deleted the 1525614-gunicorn branch February 11, 2019 18:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant