mirror of
https://github.com/krateng/maloja.git
synced 2023-08-10 21:12:55 +03:00
Added waitress warning interception
This commit is contained in:
parent
42579ad1f0
commit
4a8221f7a0
@ -4,7 +4,7 @@
|
||||
# you know what f*ck it
|
||||
# this is hardcoded for now because of that damn project / package name discrepancy
|
||||
# i'll fix it one day
|
||||
VERSION = "3.0.1"
|
||||
VERSION = "3.0.2"
|
||||
HOMEPAGE = "https://github.com/krateng/maloja"
|
||||
|
||||
|
||||
|
@ -6,6 +6,7 @@ import setproctitle
|
||||
from importlib import resources
|
||||
from css_html_js_minify import html_minify, css_minify
|
||||
import datauri
|
||||
import time
|
||||
|
||||
|
||||
# server stuff
|
||||
@ -35,7 +36,7 @@ from .proccontrol.profiler import profile
|
||||
|
||||
PORT = malojaconfig["PORT"]
|
||||
HOST = malojaconfig["HOST"]
|
||||
THREADS = 12
|
||||
THREADS = 16
|
||||
BaseRequest.MEMFILE_MAX = 15 * 1024 * 1024
|
||||
|
||||
#STATICFOLDER = importlib.resources.path(__name__,"web/static")
|
||||
@ -296,6 +297,31 @@ def redirect_track(artists,title):
|
||||
#####
|
||||
|
||||
|
||||
# warning interception
|
||||
import logging
|
||||
|
||||
class WaitressLogHandler():
|
||||
def __init__(self):
|
||||
self.lastwarned = 0
|
||||
self.barrier = 5
|
||||
self.level = 20
|
||||
self.filters = []
|
||||
def handle(self,record):
|
||||
if record.name == 'waitress.queue':
|
||||
now = time.time()
|
||||
depth = record.args[0]
|
||||
|
||||
if depth > self.barrier:
|
||||
log(f"Waitress Task Queue Depth at {depth}")
|
||||
self.lastwarned = now
|
||||
self.barrier = max(depth,self.barrier+5)
|
||||
elif now - self.lastwarned > 5:
|
||||
self.barrier = max(5,self.barrier-5)
|
||||
else:
|
||||
log(f"Waitress: {record.msg % record.args}")
|
||||
logging.getLogger().addHandler(WaitressLogHandler())
|
||||
|
||||
|
||||
def run_server():
|
||||
log("Starting up Maloja server...")
|
||||
|
||||
@ -303,6 +329,7 @@ def run_server():
|
||||
Thread(target=database.start_db).start()
|
||||
|
||||
|
||||
|
||||
try:
|
||||
#run(webserver, host=HOST, port=MAIN_PORT, server='waitress')
|
||||
log(f"Listening on {HOST}:{PORT}")
|
||||
|
@ -1,6 +1,6 @@
|
||||
[project]
|
||||
name = "malojaserver"
|
||||
version = "3.0.1"
|
||||
version = "3.0.2"
|
||||
description = "Self-hosted music scrobble database"
|
||||
readme = "./README.md"
|
||||
requires-python = ">=3.6"
|
||||
|
Loading…
Reference in New Issue
Block a user