完善直播节点监控与边缘代理
This commit is contained in:
1 parent
058bb4b99f
commit
20cd99efa4
19 files changed
+401
-47
No files matched your search
@@ -0,0 +1,27 @@
|
||||
import json
|
||||
from pathlib import Path
|
||||
|
||||
from config import settings
|
||||
|
||||
|
||||
STORE_PATH = Path(__file__).resolve().parent.parent / "nodes.json"
|
||||
|
||||
|
||||
def load_nodes() -> None:
|
||||
if not STORE_PATH.exists():
|
||||
return
|
||||
try:
|
||||
nodes = json.loads(STORE_PATH.read_text(encoding="utf-8"))
|
||||
except (OSError, json.JSONDecodeError):
|
||||
return
|
||||
if isinstance(nodes, list):
|
||||
settings.edge_nodes = nodes
|
||||
|
||||
|
||||
def save_nodes() -> None:
|
||||
temporary = STORE_PATH.with_suffix(".json.tmp")
|
||||
temporary.write_text(
|
||||
json.dumps(settings.edge_nodes, ensure_ascii=False, indent=2),
|
||||
encoding="utf-8",
|
||||
)
|
||||
temporary.replace(STORE_PATH)
|
||||
Reference in new issue
Block a user