-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1491 from fractal-analytics-platform/uvicorn-logging
Improve uvicorn/gunicorn logging
- Loading branch information
Showing
10 changed files
with
89 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
""" | ||
This module (which is only executed if `gunicorn` can be imported) subclasses | ||
the gunicorn `Logger` class in order to slightly change its log formats. | ||
This class can be used by including this `gunicorn` command-line option: | ||
``` | ||
--logger-class fractal_server.logger.gunicorn_logger.FractalGunicornLogger | ||
``` | ||
""" | ||
|
||
try: | ||
from gunicorn.glogging import Logger as GunicornLogger | ||
|
||
class FractalGunicornLogger(GunicornLogger): | ||
error_fmt = r"%(asctime)s - gunicorn.error - %(levelname)s - [pid %(process)d] - %(message)s" # noqa: E501 | ||
datefmt = r"%Y-%m-%d %H:%M:%S,%u" | ||
|
||
except (ModuleNotFoundError, ImportError): | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ fractal-server.err | |
artifacts | ||
LOG* | ||
logs | ||
logs* | ||
*.db | ||
FRACTAL_TASKS_DIR | ||
.fractal_server.env | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,4 @@ | |
rm test.db | ||
rm -r Tasks | ||
rm -r Artifacts | ||
rm logs* |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/bin/bash | ||
|
||
# Create an empty db | ||
poetry run fractalctl set-db | ||
|
||
# Start the server | ||
poetry run gunicorn fractal_server.main:app \ | ||
--workers 4 \ | ||
--worker-class uvicorn.workers.UvicornWorker \ | ||
--bind 0.0.0.0:8000 \ | ||
--access-logfile logs-fractal-server.access \ | ||
--error-logfile logs-fractal-server.error \ | ||
--logger-class fractal_server.logger.gunicorn_logger.FractalGunicornLogger \ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#!/bin/bash | ||
|
||
# Create an empty db | ||
poetry run fractalctl set-db | ||
|
||
# Start the server | ||
poetry run fractalctl start --port 8000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
from fractal_server.main import config_uvicorn_loggers | ||
|
||
|
||
def test_config_uvicorn_loggers(): | ||
""" | ||
This test simply runs `config_uvicorn_loggers`, but it does not assert | ||
anything. It is only meant to catch some trivial errors. | ||
""" | ||
config_uvicorn_loggers() |