mirror of
https://github.com/krateng/maloja.git
synced 2023-08-10 21:12:55 +03:00
More logging and documentation
This commit is contained in:
parent
634cb38dec
commit
c3e6dcd1eb
16
README.md
16
README.md
@ -55,25 +55,17 @@ Maloja should run on any x86 or ARM machine that runs Python.
|
||||
|
||||
I can support you with issues best if you use **Alpine Linux**.
|
||||
|
||||
Your CPU should have a single core passmark score of at the very least 1500. When virtualizing or containerizing, Maloja does not benefit from multiple assigned cores.
|
||||
|
||||
500 MB RAM should give you a decent experience, but performance will benefit greatly from up to 2 GB.
|
||||
Your CPU should have a single core passmark score of at the very least 1500. 500 MB RAM should give you a decent experience, but performance will benefit greatly from up to 2 GB.
|
||||
|
||||
### PyPI
|
||||
|
||||
You can download one of the included scripts in the `install` folder and run it with e.g.
|
||||
|
||||
```console
|
||||
sh install_alpine.sh
|
||||
```
|
||||
|
||||
You can also simply call the install command
|
||||
You can install Maloja with
|
||||
|
||||
```console
|
||||
pip install malojaserver
|
||||
```
|
||||
|
||||
directly - make sure you have all the system packages installed.
|
||||
To make sure all dependencies are installed, you can also use one of the included scripts in the `install` folder.
|
||||
|
||||
### From Source
|
||||
|
||||
@ -102,7 +94,7 @@ Of note are these settings which should be passed as environmental variables to
|
||||
* Mount a [volume](https://docs.docker.com/engine/reference/builder/#volume) to the specified directory to access these files outside the container (and to make them persistent)
|
||||
* `MALOJA_FORCE_PASSWORD` -- Set an admin password for maloja
|
||||
|
||||
You must publish a port on your host machine to bind to the container's web port (default 42010). Note that the Docker version uses IPv4 per default.
|
||||
You must publish a port on your host machine to bind to the container's web port (default 42010). The Docker version uses IPv4 per default.
|
||||
|
||||
An example of a minimum run configuration to access maloja via `localhost:42010`:
|
||||
|
||||
|
@ -32,7 +32,7 @@ def maintenance():
|
||||
trim_cache()
|
||||
|
||||
def print_stats():
|
||||
log(f"Cache Size: {len(cache)}, System RAM Utilization: {psutil.virtual_memory().percent}%, Cache Hits: {hits}/{hits+misses}")
|
||||
log(f"Cache Size: {len(cache)+len(entitycache)}, System RAM Utilization: {psutil.virtual_memory().percent}%, Cache Hits: {hits}/{hits+misses}")
|
||||
#print("Full rundown:")
|
||||
#import sys
|
||||
#for k in cache.keys():
|
||||
|
@ -5,6 +5,8 @@ from .dbcache import serialize
|
||||
|
||||
from ..globalconf import malojaconfig
|
||||
|
||||
from doreah.logging import log
|
||||
|
||||
|
||||
# this is a wrapper object that provides a DB connection so that one jinja page
|
||||
# (with all its included partials) can use it for all functions
|
||||
@ -14,11 +16,15 @@ from ..globalconf import malojaconfig
|
||||
class JinjaDBConnection:
|
||||
def __init__(self):
|
||||
self.cache = {}
|
||||
self.hits = 0
|
||||
self.misses = 0
|
||||
def __enter__(self):
|
||||
self.conn = engine.connect()
|
||||
return self
|
||||
def __exit__(self, exc_type, exc_value, exc_traceback):
|
||||
self.conn.close()
|
||||
log(f"Generated page with {self.hits}/{self.hits+self.misses} local Cache hits",module="debug_performance")
|
||||
del self.cache
|
||||
def __getattr__(self,name):
|
||||
originalmethod = getattr(database,name)
|
||||
|
||||
@ -29,8 +35,10 @@ class JinjaDBConnection:
|
||||
if malojaconfig['USE_REQUEST_CACHE']:
|
||||
cachekey = serialize((id(originalmethod),kwargs))
|
||||
if cachekey in self.cache:
|
||||
self.hits += 1
|
||||
return self.cache[cachekey]
|
||||
else:
|
||||
self.misses += 1
|
||||
result = originalmethod(**kwargs,dbconn=self.conn)
|
||||
self.cache[cachekey] = result
|
||||
return result
|
||||
|
@ -23,11 +23,13 @@ def profile(func):
|
||||
profiler.enable()
|
||||
result = func(*args,**kwargs)
|
||||
profiler.disable()
|
||||
|
||||
log(f"Executed {func.__name__} ({args}, {kwargs}) in {clock.stop():.2f}s",module="debug_performance")
|
||||
try:
|
||||
pstats.Stats(profiler).dump_stats(os.path.join(benchmarkfolder,f"{func.__name__}.stats"))
|
||||
except:
|
||||
pass
|
||||
log(f"Executed {func.__name__} ({args}, {kwargs}) in {clock.stop():.5f}s",module="debug_performance")
|
||||
|
||||
return result
|
||||
|
||||
return newfunc
|
||||
|
Loading…
Reference in New Issue
Block a user