-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add logging and new page after submit (#181)
- Loading branch information
Showing
9 changed files
with
187 additions
and
29 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
24 changes: 24 additions & 0 deletions
24
bfportal/core/migrations/0080_alter_experiencepagetag_tag.py
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,24 @@ | ||
# Generated by Django 4.1.7 on 2023-04-21 19:26 | ||
|
||
import django.db.models.deletion | ||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
("taggit", "0005_auto_20220424_2025"), | ||
("core", "0079_remove_experiencepage_likes"), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name="experiencepagetag", | ||
name="tag", | ||
field=models.ForeignKey( | ||
on_delete=django.db.models.deletion.CASCADE, | ||
related_name="%(app_label)s_%(class)s_items", | ||
to="taggit.tag", | ||
), | ||
), | ||
] |
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 |
---|---|---|
|
@@ -22,7 +22,7 @@ services: | |
bfportal_gg_production: | ||
image: docker.pkg.github.com/battlefield-portal-community/bfportal.gg/main:latest | ||
restart: always | ||
command: bash -c "python manage.py migrate --noinput && python manage.py ensure_superuser --username bfportal --email [email protected] --password '${SU_PASSWD}' && python manage.py ensure_initialization && gunicorn bfportal.wsgi:application --workers 4 --bind 0.0.0.0:${PRODUCTION_PORT}" | ||
command: bash -c "python manage.py migrate --noinput && python manage.py ensure_superuser --username bfportal --email [email protected] --password '${SU_PASSWD}' && python manage.py ensure_initialization && gunicorn --workers 4 --bind 0.0.0.0:${PRODUCTION_PORT}" | ||
user: "33:33" | ||
ports: | ||
- "${PRODUCTION_PORT}:${PRODUCTION_PORT}" | ||
|
@@ -75,7 +75,7 @@ services: | |
bfportal_gg_dev: | ||
image: docker.pkg.github.com/battlefield-portal-community/bfportal.gg/dev:latest | ||
restart: always | ||
command: bash -c "python manage.py migrate --noinput && python manage.py ensure_superuser --username bfportal --email [email protected] --password '${SU_PASSWD}' && python manage.py ensure_initialization && gunicorn bfportal.wsgi:application --workers 4 --bind 0.0.0.0:${DEVEL_PORT}" | ||
command: bash -c "python manage.py migrate --noinput && python manage.py ensure_superuser --username bfportal --email [email protected] --password '${SU_PASSWD}' && python manage.py ensure_initialization && gunicorn --workers 4 --bind 0.0.0.0:${DEVEL_PORT}" | ||
user: "33:33" | ||
ports: | ||
- "${DEVEL_PORT}:${DEVEL_PORT}" | ||
|
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,50 @@ | ||
from dotenv import load_dotenv | ||
|
||
load_dotenv() | ||
|
||
from bfportal.settings.base import setup_logging # noqa: E402 | ||
|
||
setup_logging() | ||
|
||
logger_class = "loguricorn.Logger" | ||
|
||
bind = "127.0.0.1:8000" | ||
reload = False | ||
timeout = 30 | ||
errorlog = "-" | ||
loglevel = "info" | ||
wsgi_app = "bfportal.wsgi:application" | ||
capture_output = True | ||
|
||
|
||
def when_ready(server): | ||
"""Called just after the master process is initialized.""" | ||
server.log.info("Server is ready. Spawning workers") | ||
|
||
|
||
def worker_int(worker): | ||
"""Called when a worker receives the INT or QUIT signal.""" | ||
worker.log.info("worker received INT or QUIT signal") | ||
|
||
# get traceback info | ||
import sys | ||
import threading | ||
import traceback | ||
|
||
id2name = {th.ident: th.name for th in threading.enumerate()} | ||
code = [] | ||
for threadId, stack in sys._current_frames().items(): | ||
code.append("\n# Thread: %s(%d)" % (id2name.get(threadId, ""), threadId)) | ||
for filename, lineno, name, line in traceback.extract_stack(stack): | ||
code.append('File: "%s", line %d, in %s' % (filename, lineno, name)) | ||
if line: | ||
code.append(" %s" % (line.strip())) | ||
worker.log.debug("\n".join(code)) | ||
|
||
|
||
def worker_abort(worker): | ||
"""Called when a worker receives the SIGABRT signal.""" | ||
worker.log.info("worker received SIGABRT signal") | ||
|
||
|
||
print("Gunicorn config loaded") |
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 |
---|---|---|
@@ -1,22 +1,22 @@ | ||
#!/usr/bin/env python | ||
import os | ||
import sys | ||
import warnings | ||
|
||
from loguru import logger | ||
from dotenv import load_dotenv | ||
|
||
load_dotenv() | ||
|
||
from bfportal.settings.base import setup_logging # noqa: E402 | ||
|
||
setup_logging() | ||
|
||
if __name__ == "__main__": | ||
logger.remove() | ||
logger.add( | ||
sys.stdout, | ||
colorize=True, | ||
format="[ <lr>bfportal</> ]" | ||
"[<b><fg #3b3b3b>{level: ^8}</></>]" | ||
"[{name}.{function}:{line}]" | ||
"[ {message} ]", | ||
level="DEBUG", | ||
) | ||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "bfportal.settings.dev") | ||
with warnings.catch_warnings(): | ||
from wagtail.utils.deprecation import RemovedInWagtail50Warning | ||
|
||
from django.core.management import execute_from_command_line | ||
warnings.filterwarnings("ignore", category=RemovedInWagtail50Warning) | ||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "bfportal.settings.dev") | ||
from django.core.management import execute_from_command_line | ||
|
||
execute_from_command_line(sys.argv) | ||
execute_from_command_line(sys.argv) |
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