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 gunicorn) || true
|
||||||
kill -9 $(pgrep memcached) || true
|
kill -9 $(pgrep memcached) || true
|
||||||
|
|
||||||
memcached -d -p 41923
|
memcached -d -p 41923 -m 1024
|
||||||
source ari-lt.env
|
source ari-lt.env
|
||||||
cd src
|
cd src
|
||||||
python3 -m pip install gunicorn
|
python3 -m pip install gunicorn
|
||||||
|
|
|
@ -6,6 +6,7 @@ import datetime
|
||||||
import hashlib
|
import hashlib
|
||||||
import os
|
import os
|
||||||
import typing as t
|
import typing as t
|
||||||
|
from multiprocessing import Manager
|
||||||
|
|
||||||
import flask
|
import flask
|
||||||
import validators
|
import validators
|
||||||
|
@ -18,10 +19,13 @@ from .limiter import limiter
|
||||||
from .routing import Bp
|
from .routing import Bp
|
||||||
|
|
||||||
views: Bp = Bp("views", __name__)
|
views: Bp = Bp("views", __name__)
|
||||||
status: t.Dict[str, t.Any] = {
|
manager = Manager()
|
||||||
"status": "<i>No status</i>",
|
status = manager.dict(
|
||||||
"last_updated": datetime.datetime.now(datetime.timezone.utc),
|
{
|
||||||
}
|
"status": "<i>No status</i>",
|
||||||
|
"last_updated": datetime.datetime.now(datetime.timezone.utc),
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@views.get("/status")
|
@views.get("/status")
|
||||||
|
@ -29,8 +33,8 @@ def get_status() -> t.Any:
|
||||||
"""Get status"""
|
"""Get status"""
|
||||||
return flask.jsonify( # type: ignore
|
return flask.jsonify( # type: ignore
|
||||||
{
|
{
|
||||||
"status": status["status"],
|
"status": status["status"], # type: ignore
|
||||||
"last_updated": status["last_updated"].timestamp(),
|
"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"]
|
and flask.request.headers.get("X-Admin-Key", None) == os.environ["ADMIN_KEY"]
|
||||||
):
|
):
|
||||||
status["status"] = str(flask.request.form["status"]) # type: ignore
|
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
|
return flask.jsonify( # type: ignore
|
||||||
{
|
{
|
||||||
"status": status["status"],
|
"status": status["status"], # type: ignore
|
||||||
"last_updated": status["last_updated"].timestamp(),
|
"last_updated": status["last_updated"].timestamp(), # type: ignore
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -175,7 +175,7 @@
|
||||||
this is a good introduction to what I do, what skills I posses.
|
this is a good introduction to what I do, what skills I posses.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<div align="center">
|
<div align="center" id="status">
|
||||||
<div><b>*** Current status ***</b></div>
|
<div><b>*** Current status ***</b></div>
|
||||||
<br />
|
<br />
|
||||||
<div>{{ status["status"] }}</div>
|
<div>{{ status["status"] }}</div>
|
||||||
|
|
Loading…
Add table
Reference in a new issue