mirror of
https://github.com/MikuLeaks/KianaBH3.git
synced 2025-12-15 14:24:34 +01:00
Initial commit
This commit is contained in:
42
game_server/config/config.py
Normal file
42
game_server/config/config.py
Normal file
@@ -0,0 +1,42 @@
|
||||
import os
|
||||
import json
|
||||
from dynaconf import Dynaconf
|
||||
|
||||
# 此处设置默认值
|
||||
Root = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
ConfigData = {
|
||||
"LogLevel": "INFO",
|
||||
"MaxSessions": 10,
|
||||
"GameServer": {
|
||||
"Ip": "127.0.0.1",
|
||||
"Port": 16100
|
||||
},
|
||||
"SdkServer": {
|
||||
"Ip": "127.0.0.1",
|
||||
"Port": 80
|
||||
},
|
||||
"VerboseLevel":1,
|
||||
"RegionName":"MikuBH3",
|
||||
"UseLocalCache":False
|
||||
}
|
||||
|
||||
class ConfigInit:
|
||||
def __init__(self):
|
||||
self.ConfigPath = f"{Root}/../Config.json"
|
||||
self.ConfigData = self.Load()
|
||||
|
||||
if not os.path.exists(self.ConfigPath):
|
||||
with open(self.ConfigPath, 'w') as f:
|
||||
json.dump(ConfigData, f, indent=4)
|
||||
|
||||
def Load(self):
|
||||
Settings = Dynaconf(
|
||||
settings_files = [self.ConfigPath],
|
||||
default_settings = ConfigData
|
||||
)
|
||||
return Settings
|
||||
|
||||
def Get(self):
|
||||
return self.ConfigData
|
||||
|
||||
Config = ConfigInit().Load()
|
||||
Reference in New Issue
Block a user