mirror of
https://codeberg.org/Freedium-cfd/web.git
synced 2026-03-11 09:04:37 +00:00
speed up: using uvicorn instead of gunicorn
This commit is contained in:
parent
e8718fd2ca
commit
68611ff6a9
4 changed files with 20 additions and 5 deletions
|
|
@ -10,3 +10,4 @@ gunicorn==21.2.0
|
|||
redis[hiredis]==4.6.0
|
||||
xkcdpass==1.19.3
|
||||
apscheduler==3.10.4
|
||||
nest-asyncio==1.6.0
|
||||
|
|
@ -1,3 +1,7 @@
|
|||
import nest_asyncio
|
||||
|
||||
nest_asyncio.apply()
|
||||
|
||||
import datetime as dt
|
||||
from loguru import logger
|
||||
import pickledb
|
||||
|
|
@ -10,17 +14,20 @@ import redis.asyncio as redis
|
|||
from xkcdpass import xkcd_password as xp
|
||||
|
||||
from server.utils.loguru_handler import InterceptHandler
|
||||
from server.utils.logger import configure_logger
|
||||
from database_lib import SQLiteCacheBackend
|
||||
|
||||
# logging.basicConfig(handlers=[InterceptHandler()], level=0, force=True)
|
||||
configure_logger()
|
||||
|
||||
medium_cache = SQLiteCacheBackend('medium_db_cache.sqlite')
|
||||
medium_cache.init_db()
|
||||
medium_cache.enable_zstd()
|
||||
|
||||
logger.debug(f"Database length: {medium_cache.all_length()}")
|
||||
|
||||
redis_storage = redis.Redis(host="dragonfly", port=6379, db=0)
|
||||
|
||||
logging.basicConfig(handlers=[InterceptHandler()], level=0, force=True)
|
||||
|
||||
url_correlation: ContextVar[Optional[str]] = ContextVar("url_correlation", default="UNKNOWN_URL")
|
||||
transponder_code_correlation: ContextVar[Optional[str]] = ContextVar("transponder_code_correlation", default="unknown transponder location... Beep!")
|
||||
|
||||
|
|
@ -33,4 +40,4 @@ WORDS_LIST_FILE = "xkcdpass/static/legac"
|
|||
|
||||
xkcd_passwd = xp.generate_wordlist(wordfile=WORDS_LIST_FILE, min_length=5, max_length=8)
|
||||
|
||||
maintenance_mode = Value('b', False)
|
||||
maintenance_mode = Value('b', False)
|
||||
|
|
|
|||
|
|
@ -24,8 +24,10 @@ def server_cmd(cmd, opts):
|
|||
if is_port_in_use(opts.port):
|
||||
cmd.error(f"Port {opts.port} is in use or permission denied")
|
||||
|
||||
from server.services.worker import execute_server_worker
|
||||
# from server.services.worker import execute_server_worker
|
||||
from server.services.server import execute_server
|
||||
from server.utils.maintenance_scheduler import do_maintenance
|
||||
|
||||
threading.Thread(target=do_maintenance, daemon=True).start()
|
||||
execute_server_worker(host="0.0.0.0", port=opts.port)
|
||||
# execute_server_worker(host="0.0.0.0", port=opts.port)
|
||||
execute_server(host="0.0.0.0", port=opts.port)
|
||||
|
|
|
|||
5
server/services/server.py
Normal file
5
server/services/server.py
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
import uvicorn
|
||||
|
||||
|
||||
def execute_server(host: str = "0.0.0.0", port: int = 7080) -> None:
|
||||
uvicorn.run("server.main:app", host=host, port=port)
|
||||
Loading…
Reference in a new issue