mirror of
https://github.com/inventree/InvenTree.git
synced 2025-06-18 04:55:44 +00:00
Improvements for docker / gunicorn (#4031)
* Additional options for gunicorn configuration file (in docker): Ref: https://pythonspeed.com/articles/gunicorn-in-docker/ * Catch potential error on startup * Tweak log message for docker * Wrap news feed update in try block
This commit is contained in:
@ -5,6 +5,7 @@ from datetime import datetime, timedelta
|
||||
|
||||
from django.conf import settings
|
||||
from django.core.exceptions import AppRegistryNotReady
|
||||
from django.db.utils import IntegrityError, OperationalError
|
||||
|
||||
import feedparser
|
||||
|
||||
@ -57,13 +58,17 @@ def update_news_feed():
|
||||
continue
|
||||
|
||||
# Create entry
|
||||
NewsFeedEntry.objects.create(
|
||||
feed_id=entry.id,
|
||||
title=entry.title,
|
||||
link=entry.link,
|
||||
published=entry.published,
|
||||
author=entry.author,
|
||||
summary=entry.summary,
|
||||
)
|
||||
try:
|
||||
NewsFeedEntry.objects.create(
|
||||
feed_id=entry.id,
|
||||
title=entry.title,
|
||||
link=entry.link,
|
||||
published=entry.published,
|
||||
author=entry.author,
|
||||
summary=entry.summary,
|
||||
)
|
||||
except (IntegrityError, OperationalError):
|
||||
# Sometimes errors-out on database start-up
|
||||
pass
|
||||
|
||||
logger.info('update_news_feed: Sync done')
|
||||
|
@ -10,6 +10,7 @@ from pathlib import Path
|
||||
from django.apps import AppConfig
|
||||
from django.conf import settings
|
||||
from django.core.exceptions import AppRegistryNotReady
|
||||
from django.db.utils import OperationalError
|
||||
|
||||
from InvenTree.ready import canAppAccessDatabase
|
||||
|
||||
@ -35,18 +36,18 @@ class LabelConfig(AppConfig):
|
||||
def ready(self):
|
||||
"""This function is called whenever the label app is loaded."""
|
||||
if canAppAccessDatabase():
|
||||
self.create_labels() # pragma: no cover
|
||||
|
||||
try:
|
||||
self.create_labels() # pragma: no cover
|
||||
except (AppRegistryNotReady, OperationalError):
|
||||
# Database might not yet be ready
|
||||
warnings.warn('Database was not ready for creating labels')
|
||||
|
||||
def create_labels(self):
|
||||
"""Create all default templates."""
|
||||
# Test if models are ready
|
||||
try:
|
||||
from .models import PartLabel, StockItemLabel, StockLocationLabel
|
||||
assert bool(StockLocationLabel is not None)
|
||||
except AppRegistryNotReady: # pragma: no cover
|
||||
# Database might not yet be ready
|
||||
warnings.warn('Database was not ready for creating labels')
|
||||
return
|
||||
from .models import PartLabel, StockItemLabel, StockLocationLabel
|
||||
assert bool(StockLocationLabel is not None)
|
||||
|
||||
# Create the categories
|
||||
self.create_labels_category(
|
||||
@ -62,6 +63,7 @@ class LabelConfig(AppConfig):
|
||||
},
|
||||
],
|
||||
)
|
||||
|
||||
self.create_labels_category(
|
||||
StockLocationLabel,
|
||||
'stocklocation',
|
||||
@ -82,6 +84,7 @@ class LabelConfig(AppConfig):
|
||||
}
|
||||
]
|
||||
)
|
||||
|
||||
self.create_labels_category(
|
||||
PartLabel,
|
||||
'part',
|
||||
|
Reference in New Issue
Block a user