serverwatcher 3.4__tar.gz → 3.5.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {serverwatcher-3.4/src/serverwatcher.egg-info → serverwatcher-3.5.1}/PKG-INFO +1 -1
- {serverwatcher-3.4 → serverwatcher-3.5.1}/pyproject.toml +1 -1
- {serverwatcher-3.4 → serverwatcher-3.5.1}/src/serverwatcher/__init__.py +2 -1
- serverwatcher-3.5.1/src/serverwatcher/defaultconfigs/watcher.yaml +39 -0
- {serverwatcher-3.4 → serverwatcher-3.5.1}/src/serverwatcher/schema.py +25 -0
- {serverwatcher-3.4 → serverwatcher-3.5.1}/src/serverwatcher/watcher.py +4 -1
- {serverwatcher-3.4 → serverwatcher-3.5.1/src/serverwatcher.egg-info}/PKG-INFO +1 -1
- serverwatcher-3.4/src/serverwatcher/defaultconfigs/watcher.yaml +0 -32
- {serverwatcher-3.4 → serverwatcher-3.5.1}/LICENSE +0 -0
- {serverwatcher-3.4 → serverwatcher-3.5.1}/README.md +0 -0
- {serverwatcher-3.4 → serverwatcher-3.5.1}/setup.cfg +0 -0
- {serverwatcher-3.4 → serverwatcher-3.5.1}/src/serverwatcher/config/__init__.py +0 -0
- {serverwatcher-3.4 → serverwatcher-3.5.1}/src/serverwatcher/config/global_config.py +0 -0
- {serverwatcher-3.4 → serverwatcher-3.5.1}/src/serverwatcher/config/messages.py +0 -0
- {serverwatcher-3.4 → serverwatcher-3.5.1}/src/serverwatcher/config/watcher.py +0 -0
- {serverwatcher-3.4 → serverwatcher-3.5.1}/src/serverwatcher/defaultconfigs/global.yaml +0 -0
- {serverwatcher-3.4 → serverwatcher-3.5.1}/src/serverwatcher/defaultconfigs/messages.yaml +0 -0
- {serverwatcher-3.4 → serverwatcher-3.5.1}/src/serverwatcher.egg-info/SOURCES.txt +0 -0
- {serverwatcher-3.4 → serverwatcher-3.5.1}/src/serverwatcher.egg-info/dependency_links.txt +0 -0
- {serverwatcher-3.4 → serverwatcher-3.5.1}/src/serverwatcher.egg-info/requires.txt +0 -0
- {serverwatcher-3.4 → serverwatcher-3.5.1}/src/serverwatcher.egg-info/top_level.txt +0 -0
|
@@ -7,7 +7,7 @@ except PackageNotFoundError:
|
|
|
7
7
|
__version__ = '0.0.0'
|
|
8
8
|
|
|
9
9
|
from .watcher import ServerWatcher
|
|
10
|
-
from .schema import validate_config_schema, validate_messages_schema
|
|
10
|
+
from .schema import validate_config_schema, validate_messages_schema, flatten_nested
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
__all__ = [
|
|
@@ -15,4 +15,5 @@ __all__ = [
|
|
|
15
15
|
'ServerWatcher',
|
|
16
16
|
'validate_config_schema',
|
|
17
17
|
'validate_messages_schema',
|
|
18
|
+
'flatten_nested',
|
|
18
19
|
]
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
logging:
|
|
2
|
+
logger_name_template: "Server Watcher"
|
|
3
|
+
log_path: "/home/container/logs/"
|
|
4
|
+
timezone: "America/Chicago"
|
|
5
|
+
|
|
6
|
+
terminal_settings:
|
|
7
|
+
console_backspaces: 8
|
|
8
|
+
clear_terminal: True
|
|
9
|
+
|
|
10
|
+
schedules:
|
|
11
|
+
restart_soon_schedule_id: 0 # replace this with real schedule id
|
|
12
|
+
origin_disable_schedule_id: 0 # replace this with real schedule id
|
|
13
|
+
|
|
14
|
+
thresolds:
|
|
15
|
+
ram_threshold: 6
|
|
16
|
+
cpu_threshold: 150
|
|
17
|
+
uptime_hours_threshold: 12
|
|
18
|
+
tps_threshold: 19.5
|
|
19
|
+
|
|
20
|
+
weights:
|
|
21
|
+
weight_restart_soon: 3
|
|
22
|
+
weight_ram: 1
|
|
23
|
+
weight_cpu: 1
|
|
24
|
+
weight_uptime: 1
|
|
25
|
+
weight_tps: 1
|
|
26
|
+
weight_low_uptime: 5
|
|
27
|
+
weight_per_player: 1
|
|
28
|
+
|
|
29
|
+
gaps:
|
|
30
|
+
low_gap_minutes: 120
|
|
31
|
+
high_gap_minutes: 60
|
|
32
|
+
|
|
33
|
+
restart_intervals:
|
|
34
|
+
restart_wait_seconds: 45
|
|
35
|
+
restart_online_timeout: 120
|
|
36
|
+
restart_online_interval: 2
|
|
37
|
+
|
|
38
|
+
watcher_intervals:
|
|
39
|
+
watch_interval: 60
|
|
@@ -43,3 +43,28 @@ def validate_messages_schema(raw: Dict[str, Any]) -> list[str]:
|
|
|
43
43
|
if "prefix" not in raw:
|
|
44
44
|
errors.append("[messages] Missing required key: 'prefix'")
|
|
45
45
|
return errors
|
|
46
|
+
|
|
47
|
+
def flatten_nested(raw: dict) -> dict:
|
|
48
|
+
"""
|
|
49
|
+
Recursively flattens a nested YAML dict into a single-level dict.
|
|
50
|
+
Section names are ignored; only leaf keys matter.
|
|
51
|
+
"""
|
|
52
|
+
flat = {}
|
|
53
|
+
|
|
54
|
+
def walk(node):
|
|
55
|
+
if isinstance(node, dict):
|
|
56
|
+
for v in node.values():
|
|
57
|
+
walk(v)
|
|
58
|
+
else:
|
|
59
|
+
# ignore non-dict nodes at this level
|
|
60
|
+
pass
|
|
61
|
+
|
|
62
|
+
def collect(node):
|
|
63
|
+
for key, value in node.items():
|
|
64
|
+
if isinstance(value, dict):
|
|
65
|
+
collect(value)
|
|
66
|
+
else:
|
|
67
|
+
flat[key] = value
|
|
68
|
+
|
|
69
|
+
collect(raw)
|
|
70
|
+
return flat
|
|
@@ -15,6 +15,7 @@ from hungerlib.addons import (
|
|
|
15
15
|
map_to_dataclass,
|
|
16
16
|
)
|
|
17
17
|
|
|
18
|
+
from serverwatcher.schema import flatten_nested
|
|
18
19
|
from serverwatcher.config import GlobalConfig, MessagesConfig, WatcherConfig
|
|
19
20
|
|
|
20
21
|
# Set directory
|
|
@@ -37,7 +38,9 @@ def load_or_default(path: str, default_path: str, schema):
|
|
|
37
38
|
dst.write(src.read())
|
|
38
39
|
|
|
39
40
|
raw = load_yaml(abs_path)
|
|
41
|
+
raw = flatten_nested(raw)
|
|
40
42
|
return map_to_dataclass(raw, schema)
|
|
43
|
+
|
|
41
44
|
|
|
42
45
|
|
|
43
46
|
# Main watcher
|
|
@@ -192,7 +195,7 @@ class ServerWatcher:
|
|
|
192
195
|
restart_reasons.append(
|
|
193
196
|
self.fmt(self.messages.reason_ram, ram=snap.ram, threshold=self.cfg.ram_threshold)
|
|
194
197
|
)
|
|
195
|
-
pro += round(snap.ram, 0) - 5
|
|
198
|
+
pro += int(round(snap.ram, 0) - 5)
|
|
196
199
|
|
|
197
200
|
if snap.cpu >= self.cfg.cpu_threshold:
|
|
198
201
|
restart_reasons.append(
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
restart_soon_schedule_id: 13
|
|
2
|
-
origin_disable_schedule_id: 11
|
|
3
|
-
|
|
4
|
-
ram_threshold: 6
|
|
5
|
-
cpu_threshold: 150
|
|
6
|
-
uptime_hours_threshold: 12
|
|
7
|
-
tps_threshold: 19.5
|
|
8
|
-
|
|
9
|
-
weight_restart_soon: 3
|
|
10
|
-
weight_ram: 1
|
|
11
|
-
weight_cpu: 1
|
|
12
|
-
weight_uptime: 1
|
|
13
|
-
weight_tps: 1
|
|
14
|
-
|
|
15
|
-
weight_low_uptime: 5
|
|
16
|
-
weight_per_player: 1
|
|
17
|
-
|
|
18
|
-
low_gap_minutes: 120
|
|
19
|
-
high_gap_minutes: 60
|
|
20
|
-
|
|
21
|
-
restart_wait_seconds: 45
|
|
22
|
-
restart_online_timeout: 120
|
|
23
|
-
restart_online_interval: 2
|
|
24
|
-
|
|
25
|
-
logger_name_template: "Server Watcher"
|
|
26
|
-
log_path: "/home/container/logs/"
|
|
27
|
-
console_backspaces: 8
|
|
28
|
-
timezone: "America/Chicago"
|
|
29
|
-
|
|
30
|
-
# New values (will reorder later)
|
|
31
|
-
watch_interval: 60
|
|
32
|
-
clear_terminal: True
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|