Openverse is a search engine for openly-licensed media. This monorepo includes all application code.
Improve and unify ingestion server logging, simplify docker CMDs (#2639)
Madison Swain-Bowdendd49aeaec156
diff --git a/docker-compose.yml b/docker-compose.ymlindex e11c6b2b0..6bff3f6e4 100644--- a/docker-compose.yml+++ b/docker-compose.yml@@ -240,7 +240,6 @@ services:args: # Automatically inferred from env vars, unless specified- INGESTION_PY_VERSIONimage: openverse-ingestion_server- command: gunicorn -c ./gunicorn.conf.pyports:- "50281:8001"depends_on:@@ -266,7 +265,7 @@ services:args: # Automatically inferred from env vars, unless specified- INGESTION_PY_VERSIONimage: openverse-ingestion_server- command: gunicorn -c ./gunicorn_worker.conf.py+ command: gunicorn indexer_worker:api --bind 0.0.0.0:8002expose:- "8002"depends_on:diff --git a/ingestion_server/Dockerfile b/ingestion_server/Dockerfileindex 2b0e95b90..f3b670639 100644--- a/ingestion_server/Dockerfile+++ b/ingestion_server/Dockerfile@@ -78,4 +78,4 @@ COPY --chown=ingestionu . /ingestion_server/# - 8002: Gunicorn server for `indexer_worker` Falcon appEXPOSE 8001 8002-# CMD is set from Docker Compose+CMD ["gunicorn", "--bind", "0.0.0.0:8001", "api:api"]diff --git a/ingestion_server/docker-compose.yml b/ingestion_server/docker-compose.ymldeleted file mode 100644index 8bd64d2cc..000000000--- a/ingestion_server/docker-compose.yml+++ /dev/null@@ -1,15 +0,0 @@-version: "2.4"-services:- ingestion_server:- # Allow the image tag to be set to a specific version, default to latest- image: ghcr.io/wordpress/openverse-ingestion_server:${IMAGE_TAG:-latest}- ports:- - "8001:8001"- env_file:- - .env- dns:- # Related to DNS management on the production box.- # 172.16.0.0–172.31.255.255 is a reserved IP range by the (IANA) for- # private/internal networking. This specific IP is the DNS resolution address- # for a default AWS Virtual Private Cloud.- - 172.31.0.2diff --git a/ingestion_server/gunicorn.conf.py b/ingestion_server/gunicorn.conf.pyindex bc15b4447..842c29b2b 100644--- a/ingestion_server/gunicorn.conf.py+++ b/ingestion_server/gunicorn.conf.py@@ -1,7 +1,44 @@-bind = ["0.0.0.0:8001"]capture_output = True+accesslog = "-"+errorlog = "-"chdir = "./ingestion_server/"timeout = 120reload = 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"diff --git a/ingestion_server/gunicorn_worker.conf.py b/ingestion_server/gunicorn_worker.conf.pydeleted file mode 100644index df032c58e..000000000--- a/ingestion_server/gunicorn_worker.conf.py+++ /dev/null@@ -1,9 +0,0 @@-bind = ["0.0.0.0:8002"]-capture_output = True-chdir = "./ingestion_server/"-timeout = 120-reload = True-loglevel = "debug"-wsgi_app = "indexer_worker:api"-accesslog = "-"-errorlog = "-"diff --git a/ingestion_server/ingestion_server/api.py b/ingestion_server/ingestion_server/api.pyindex c99f12f66..240a095b4 100644--- a/ingestion_server/ingestion_server/api.py+++ b/ingestion_server/ingestion_server/api.py@@ -2,7 +2,6 @@import loggingimport os-import sysimport timeimport uuidfrom multiprocessing import Process, Value@@ -323,20 +322,9 @@ class StateResource: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()diff --git a/ingestion_server/ingestion_server/indexer_worker.py b/ingestion_server/ingestion_server/indexer_worker.pyindex d6631b01b..3b280ffa4 100644--- a/ingestion_server/ingestion_server/indexer_worker.py+++ b/ingestion_server/ingestion_server/indexer_worker.py@@ -6,7 +6,6 @@ data has been indexed, notify Ingestion Server and stop the instance."""import logging as log-import sysfrom multiprocessing import Processimport boto3@@ -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())