dev@locazia: add service healthy montoring
This commit is contained in:
1 parent
e0a4514fef
commit
fcc5ccbe65
9 files changed
+139
-16
No files matched your search
@@ -0,0 +1,29 @@
|
||||
from httpx import AsyncClient
|
||||
from app.core._config import PROJECT_HOST
|
||||
from app.core.logger import make_log
|
||||
from app.core._secrets import hot_privkey
|
||||
from tonsdk.utils import sign_message
|
||||
from base58 import b58encode
|
||||
from json import dumps
|
||||
from app.core._crypto.signer import Signer
|
||||
|
||||
|
||||
async def send_status(service: str, status: str):
|
||||
message = {
|
||||
'service': service,
|
||||
'status': status,
|
||||
}
|
||||
message_bytes = dumps(message).encode()
|
||||
signer = Signer(hot_privkey)
|
||||
message_signature = signer.sign(message_bytes)
|
||||
async with AsyncClient() as client:
|
||||
res = await client.post(
|
||||
f"{PROJECT_HOST}/api/system.sendStatus",
|
||||
json={
|
||||
'message': b58encode(message_bytes).decode(),
|
||||
'signature': message_signature,
|
||||
}
|
||||
)
|
||||
if res.status_code != 200:
|
||||
make_log("send_status", f"Error (service={service}, status={status}, response={res.text})", level='error')
|
||||
|
||||
Reference in new issue
Block a user