mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Postgresql fix (#6441)
* Assume maintenance mode is *on* if database is inaccessible * Specify ash shell * Update psycopg requirements * Style fixes * style fix - backends.py
This commit is contained in:
parent
edd6f25411
commit
22af3e2f59
@ -84,7 +84,7 @@ RUN if [ `apk --print-arch` = "armv7" ]; then \
|
||||
COPY tasks.py docker/gunicorn.conf.py docker/init.sh ./
|
||||
RUN chmod +x init.sh
|
||||
|
||||
ENTRYPOINT ["/bin/sh", "./init.sh"]
|
||||
ENTRYPOINT ["/bin/ash", "./init.sh"]
|
||||
|
||||
FROM inventree_base as prebuild
|
||||
|
||||
|
@ -28,11 +28,16 @@ class InvenTreeMaintenanceModeBackend(AbstractStateBackend):
|
||||
Returns:
|
||||
bool: True if maintenance mode is active, False otherwise.
|
||||
"""
|
||||
value = InvenTree.helpers.str2bool(
|
||||
common.models.InvenTreeSetting.get_setting(
|
||||
self.SETTING_KEY, backup_value=False, create=False, cache=False
|
||||
)
|
||||
)
|
||||
try:
|
||||
setting = common.models.InvenTreeSetting.objects.get(key=self.SETTING_KEY)
|
||||
value = InvenTree.helpers.str2bool(setting.value)
|
||||
except common.models.InvenTreeSetting.DoesNotExist:
|
||||
# Database is accessible, but setting is not available - assume False
|
||||
value = False
|
||||
except (IntegrityError, OperationalError, ProgrammingError):
|
||||
# Database is inaccessible - assume we are not in maintenance mode
|
||||
logger.warning('Failed to read maintenance mode state - assuming True')
|
||||
value = True
|
||||
|
||||
logger.debug('Maintenance mode state: %s', value)
|
||||
|
||||
@ -50,10 +55,13 @@ class InvenTreeMaintenanceModeBackend(AbstractStateBackend):
|
||||
if self.get_value() == value:
|
||||
break
|
||||
except (IntegrityError, OperationalError, ProgrammingError):
|
||||
logger.warning(
|
||||
'Failed to set maintenance mode state in database (%s retries left)',
|
||||
retries,
|
||||
# In the database is locked, then
|
||||
logger.debug(
|
||||
'Failed to set maintenance mode state (%s retries left)', retries
|
||||
)
|
||||
time.sleep(0.1)
|
||||
|
||||
retries -= 1
|
||||
|
||||
if retries == 0:
|
||||
logger.warning('Failed to set maintenance mode state')
|
||||
|
@ -1,4 +1,5 @@
|
||||
#!/bin/sh
|
||||
#!/bin/ash
|
||||
|
||||
# exit when any command fails
|
||||
set -e
|
||||
|
||||
|
@ -7,7 +7,7 @@ setuptools>=69.0.0
|
||||
wheel>=0.41.0
|
||||
|
||||
# Database links
|
||||
psycopg[binary]>=3.1.18
|
||||
psycopg[binary, c, pool]
|
||||
mysqlclient>=2.2.0
|
||||
mariadb>=1.1.8
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user