mirror of
https://git.ari.lt/ari.lt/ari.lt.git
synced 2025-02-04 09:39:25 +01:00
Improve multiprocessing capabilities.
Signed-off-by: Ari Archer <ari@ari.lt>
This commit is contained in:
parent
6570564cbe
commit
6cb94ef447
3 changed files with 15 additions and 11 deletions
2
run.sh
2
run.sh
|
@ -7,7 +7,7 @@ main() {
|
|||
kill -9 $(pgrep gunicorn) || true
|
||||
kill -9 $(pgrep memcached) || true
|
||||
|
||||
memcached -d -p 41923
|
||||
memcached -d -p 41923 -m 1024
|
||||
source ari-lt.env
|
||||
cd src
|
||||
python3 -m pip install gunicorn
|
||||
|
|
|
@ -6,6 +6,7 @@ import datetime
|
|||
import hashlib
|
||||
import os
|
||||
import typing as t
|
||||
from multiprocessing import Manager
|
||||
|
||||
import flask
|
||||
import validators
|
||||
|
@ -18,10 +19,13 @@ from .limiter import limiter
|
|||
from .routing import Bp
|
||||
|
||||
views: Bp = Bp("views", __name__)
|
||||
status: t.Dict[str, t.Any] = {
|
||||
"status": "<i>No status</i>",
|
||||
"last_updated": datetime.datetime.now(datetime.timezone.utc),
|
||||
}
|
||||
manager = Manager()
|
||||
status = manager.dict(
|
||||
{
|
||||
"status": "<i>No status</i>",
|
||||
"last_updated": datetime.datetime.now(datetime.timezone.utc),
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
@views.get("/status")
|
||||
|
@ -29,8 +33,8 @@ def get_status() -> t.Any:
|
|||
"""Get status"""
|
||||
return flask.jsonify( # type: ignore
|
||||
{
|
||||
"status": status["status"],
|
||||
"last_updated": status["last_updated"].timestamp(),
|
||||
"status": status["status"], # type: ignore
|
||||
"last_updated": status["last_updated"].timestamp(), # type: ignore
|
||||
}
|
||||
)
|
||||
|
||||
|
@ -60,11 +64,11 @@ def set_status() -> Response:
|
|||
and flask.request.headers.get("X-Admin-Key", None) == os.environ["ADMIN_KEY"]
|
||||
):
|
||||
status["status"] = str(flask.request.form["status"]) # type: ignore
|
||||
status["last_updated"] = datetime.datetime.now(datetime.timezone.utc)
|
||||
status["last_updated"] = datetime.datetime.now(datetime.timezone.utc) # type: ignore
|
||||
return flask.jsonify( # type: ignore
|
||||
{
|
||||
"status": status["status"],
|
||||
"last_updated": status["last_updated"].timestamp(),
|
||||
"status": status["status"], # type: ignore
|
||||
"last_updated": status["last_updated"].timestamp(), # type: ignore
|
||||
}
|
||||
)
|
||||
else:
|
||||
|
|
|
@ -175,7 +175,7 @@
|
|||
this is a good introduction to what I do, what skills I posses.
|
||||
</p>
|
||||
|
||||
<div align="center">
|
||||
<div align="center" id="status">
|
||||
<div><b>*** Current status ***</b></div>
|
||||
<br />
|
||||
<div>{{ status["status"] }}</div>
|
||||
|
|
Loading…
Add table
Reference in a new issue