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

Improve and unify ingestion server logging, simplify docker CMDs #2639

Merged
merged 7 commits into from
Jul 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,6 @@ services:
args: # Automatically inferred from env vars, unless specified
- INGESTION_PY_VERSION
image: openverse-ingestion_server
command: gunicorn -c ./gunicorn.conf.py
ports:
- "50281:8001"
depends_on:
Expand All @@ -266,7 +265,7 @@ services:
args: # Automatically inferred from env vars, unless specified
- INGESTION_PY_VERSION
image: openverse-ingestion_server
command: gunicorn -c ./gunicorn_worker.conf.py
command: gunicorn indexer_worker:api --bind 0.0.0.0:8002
expose:
- "8002"
depends_on:
Expand Down
2 changes: 1 addition & 1 deletion ingestion_server/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,4 @@ COPY --chown=ingestionu . /ingestion_server/
# - 8002: Gunicorn server for `indexer_worker` Falcon app
EXPOSE 8001 8002

# CMD is set from Docker Compose
CMD ["gunicorn", "--bind", "0.0.0.0:8001", "api:api"]
15 changes: 0 additions & 15 deletions ingestion_server/docker-compose.yml

This file was deleted.

41 changes: 39 additions & 2 deletions ingestion_server/gunicorn.conf.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,44 @@
bind = ["0.0.0.0:8001"]
capture_output = True
accesslog = "-"
errorlog = "-"
chdir = "./ingestion_server/"
timeout = 120
reload = True
logconfig_dict = {
# NOTE: Most of this is inherited from the default configuration
# https://github.com/benoitc/gunicorn/blob/cc2e3835784542e65886cd27f64d444309fbaad0/gunicorn/glogging.py#L48-L86
"version": 1,
"disable_existing_loggers": False,
"formatters": {
"generic": {
"format": "[%(asctime)s - %(name)s - %(lineno)3d][%(levelname)s] %(message)s", # noqa: E501
},
},
"root": {"level": "INFO", "handlers": ["console"]},
"loggers": {
"gunicorn.error": {
"level": "DEBUG",
"handlers": ["console"],
"propagate": False, # Prevents default handler from also logging this
"qualname": "gunicorn.error",
},
"gunicorn.access": {
"level": "INFO",
"handlers": ["console"],
"propagate": False, # Prevents default handler from also logging this
"qualname": "gunicorn.access",
},
"": {
"level": "INFO",
"handlers": ["console"],
},
},
"handlers": {
"console": {
"class": "logging.StreamHandler",
"formatter": "generic",
"stream": "ext://sys.stdout",
},
},
}
loglevel = "debug"
wsgi_app = "api:api"
9 changes: 0 additions & 9 deletions ingestion_server/gunicorn_worker.conf.py

This file was deleted.

14 changes: 1 addition & 13 deletions ingestion_server/ingestion_server/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import logging
import os
import sys
import time
import uuid
from multiprocessing import Process, Value
Expand Down Expand Up @@ -323,20 +322,9 @@ def on_delete(_, __):
clear_state()


def create_api(log=True):
def create_api():
"""Create an instance of the Falcon API server."""

if log:
root = logging.getLogger()
root.setLevel(logging.DEBUG)
handler = logging.StreamHandler(sys.stdout)
handler.setLevel(logging.INFO)
formatter = logging.Formatter(
"%(asctime)s %(levelname)s %(filename)s:%(lineno)d - %(message)s"
)
handler.setFormatter(formatter)
root.addHandler(handler)

_api = falcon.App()

task_tracker = TaskTracker()
Expand Down
10 changes: 0 additions & 10 deletions ingestion_server/ingestion_server/indexer_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
"""

import logging as log
import sys
from multiprocessing import Process

import boto3
Expand Down Expand Up @@ -111,15 +110,6 @@ def _self_destruct():
ec2_client.stop_instances(InstanceIds=[instance_id])


root = log.getLogger()
root.setLevel(log.DEBUG)
handler = log.StreamHandler(sys.stdout)
handler.setLevel(log.INFO)
formatter = log.Formatter(
"%(asctime)s %(levelname)s %(filename)s:%(lineno)d - %(message)s"
)
handler.setFormatter(formatter)
root.addHandler(handler)
api = falcon.App()
api.add_route("/indexing_task", IndexingJobResource())
api.add_route("/healthcheck", HealthcheckResource())