mirror of
https://github.com/PluralKit/PluralKit.git
synced 2026-02-13 09:10:14 +00:00
Add occasional basic stat reporting to InfluxDB
This commit is contained in:
parent
ec5a023348
commit
f50a08b50b
3 changed files with 37 additions and 0 deletions
|
|
@ -1,3 +1,4 @@
|
|||
import asyncio
|
||||
from datetime import datetime
|
||||
import logging
|
||||
import json
|
||||
|
|
@ -90,6 +91,13 @@ async def on_socket_raw_receive(msg):
|
|||
except ValueError:
|
||||
pass
|
||||
|
||||
async def periodical_stat_timer(pool):
|
||||
async with pool.acquire() as conn:
|
||||
while True:
|
||||
from pluralkit import stats
|
||||
await stats.report_periodical_stats(conn)
|
||||
await asyncio.sleep(30)
|
||||
|
||||
async def run():
|
||||
from pluralkit import db, stats
|
||||
try:
|
||||
|
|
@ -102,6 +110,9 @@ async def run():
|
|||
|
||||
logger.info("Connecting to InfluxDB...")
|
||||
await stats.connect()
|
||||
|
||||
logger.info("Starting periodical stat reporting...")
|
||||
asyncio.get_event_loop().create_task(periodical_stat_timer(pool))
|
||||
|
||||
client.pool = pool
|
||||
logger.info("Connecting to Discord...")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue