mirror of
https://github.com/MikroWizard/mikroman.git
synced 2025-07-13 23:44:34 +02:00
Reload server if db connection failed
This commit is contained in:
parent
4af68c2fb7
commit
08cd3d0e1a
1 changed files with 8 additions and 2 deletions
|
@ -6,7 +6,7 @@
|
|||
# Author: sepehr.ha@gmail.com
|
||||
|
||||
from peewee import *
|
||||
|
||||
from pathlib import Path
|
||||
from libs.db.db import User,BaseModel,get_object_or_404
|
||||
import logging
|
||||
log = logging.getLogger("db_sysconfig")
|
||||
|
@ -44,7 +44,13 @@ def get_scan_mode():
|
|||
return get_object_or_404(Sysconfig, key="scan_mode")
|
||||
|
||||
def get_sysconfig(key):
|
||||
try:
|
||||
return get_object_or_404(Sysconfig, key=key).value
|
||||
except Exception as e:
|
||||
log.error(e)
|
||||
if "server closed the connection unexpectedly" in str(e):
|
||||
Path('/app/reload').touch()
|
||||
return None
|
||||
|
||||
def get_firmware_latest():
|
||||
return get_object_or_404(Sysconfig, key="latest_version")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue