mirror of
https://github.com/krateng/maloja.git
synced 2023-08-10 21:12:55 +03:00
Improved aux mode again
This commit is contained in:
parent
05759314f0
commit
d8e5f6552e
@ -2,20 +2,12 @@
|
||||
from bottle import request, response, FormsDict
|
||||
|
||||
|
||||
# we're running an auxiliary task that doesn't require all the random background
|
||||
# nonsense to be fired up
|
||||
# this is temporary
|
||||
# FIX YO DAMN ARCHITECTURE ALREADY
|
||||
AUX_MODE = False
|
||||
def set_aux_mode():
|
||||
global AUX_MODE
|
||||
AUX_MODE = True
|
||||
|
||||
# decorator that makes sure this function is only run in normal operation,
|
||||
# not when we run a task that needs to access the database
|
||||
def no_aux_mode(func):
|
||||
def wrapper(*args,**kwargs):
|
||||
if AUX_MODE: return
|
||||
from ..pkg_global import conf
|
||||
if conf.AUX_MODE: return
|
||||
return func(*args,**kwargs)
|
||||
return wrapper
|
||||
|
||||
|
@ -98,7 +98,6 @@ if malojaconfig['USE_GLOBAL_CACHE']:
|
||||
def invalidate_entity_cache():
|
||||
entitycache.clear()
|
||||
|
||||
@no_aux_mode
|
||||
def trim_cache():
|
||||
ramprct = psutil.virtual_memory().percent
|
||||
if ramprct > malojaconfig["DB_MAX_MEMORY"]:
|
||||
|
@ -6,6 +6,8 @@ from doreah.configuration import types as tp
|
||||
from ..__pkginfo__ import VERSION
|
||||
|
||||
|
||||
# this mode specifies whether we run some auxiliary task instead of the main server
|
||||
AUX_MODE = True
|
||||
|
||||
|
||||
# if DATA_DIRECTORY is specified, this is the directory to use for EVERYTHING, no matter what
|
||||
|
@ -21,9 +21,6 @@ outputs = {
|
||||
|
||||
def import_scrobbles(inputf):
|
||||
|
||||
from ...database import set_aux_mode
|
||||
set_aux_mode()
|
||||
|
||||
from ...database.sqldb import add_scrobbles
|
||||
|
||||
result = {
|
||||
|
@ -1,11 +1,7 @@
|
||||
|
||||
|
||||
from doreah.io import col
|
||||
|
||||
def parse_albums(replace=False):
|
||||
|
||||
from ...database import set_aux_mode
|
||||
set_aux_mode()
|
||||
|
||||
from ...database.sqldb import guess_albums, get_album_id, add_track_to_album
|
||||
|
||||
print("Parsing album information...")
|
||||
|
@ -22,6 +22,7 @@ from .database.jinjaview import JinjaDBConnection
|
||||
from .images import resolve_track_image, resolve_artist_image, resolve_album_image
|
||||
from .malojauri import uri_to_internal, remove_identical
|
||||
from .pkg_global.conf import malojaconfig, data_dir
|
||||
from .pkg_global import conf
|
||||
from .jinjaenv.context import jinja_environment
|
||||
from .apis import init_apis, apikeystore
|
||||
|
||||
@ -285,6 +286,8 @@ logging.getLogger().addHandler(WaitressLogHandler())
|
||||
|
||||
|
||||
def run_server():
|
||||
conf.AUX_MODE = False
|
||||
|
||||
log("Starting up Maloja server...")
|
||||
|
||||
## start database
|
||||
|
Loading…
Reference in New Issue
Block a user