serverwatcher 5.1__tar.gz → 5.1.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-5.1/src/serverwatcher.egg-info → serverwatcher-5.1.1}/PKG-INFO +1 -1
- {serverwatcher-5.1 → serverwatcher-5.1.1}/pyproject.toml +1 -1
- {serverwatcher-5.1 → serverwatcher-5.1.1}/src/serverwatcher/configclasses/messages.py +7 -7
- serverwatcher-5.1.1/src/serverwatcher/configclasses/watcher.py +30 -0
- {serverwatcher-5.1 → serverwatcher-5.1.1}/src/serverwatcher/validator.py +8 -8
- {serverwatcher-5.1 → serverwatcher-5.1.1}/src/serverwatcher/watcher.py +21 -21
- {serverwatcher-5.1 → serverwatcher-5.1.1/src/serverwatcher.egg-info}/PKG-INFO +1 -1
- serverwatcher-5.1/src/serverwatcher/configclasses/watcher.py +0 -30
- {serverwatcher-5.1 → serverwatcher-5.1.1}/LICENSE +0 -0
- {serverwatcher-5.1 → serverwatcher-5.1.1}/README.md +0 -0
- {serverwatcher-5.1 → serverwatcher-5.1.1}/setup.cfg +0 -0
- {serverwatcher-5.1 → serverwatcher-5.1.1}/src/serverwatcher/__init__.py +0 -0
- {serverwatcher-5.1 → serverwatcher-5.1.1}/src/serverwatcher/configclasses/__init__.py +0 -0
- {serverwatcher-5.1 → serverwatcher-5.1.1}/src/serverwatcher/configclasses/config.py +0 -0
- {serverwatcher-5.1 → serverwatcher-5.1.1}/src/serverwatcher/defaultconfigs/config.yaml +0 -0
- {serverwatcher-5.1 → serverwatcher-5.1.1}/src/serverwatcher/defaultconfigs/messages.yaml +0 -0
- {serverwatcher-5.1 → serverwatcher-5.1.1}/src/serverwatcher/defaultconfigs/watcher.yaml +0 -0
- {serverwatcher-5.1 → serverwatcher-5.1.1}/src/serverwatcher.egg-info/SOURCES.txt +0 -0
- {serverwatcher-5.1 → serverwatcher-5.1.1}/src/serverwatcher.egg-info/dependency_links.txt +0 -0
- {serverwatcher-5.1 → serverwatcher-5.1.1}/src/serverwatcher.egg-info/requires.txt +0 -0
- {serverwatcher-5.1 → serverwatcher-5.1.1}/src/serverwatcher.egg-info/top_level.txt +0 -0
|
@@ -44,13 +44,13 @@ class MessagesConfig:
|
|
|
44
44
|
pro_restart_splash: str = yaml_key("reasons.pro_restart_splash")
|
|
45
45
|
anti_restart_splash: str = yaml_key("reasons.anti_restart_splash")
|
|
46
46
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
47
|
+
reason_restart_soon: str = yaml_key("reasons.restart_soon")
|
|
48
|
+
reason_ram: str = yaml_key("reasons.ram")
|
|
49
|
+
reason_cpu: str = yaml_key("reasons.cpu")
|
|
50
|
+
reason_uptime: str = yaml_key("reasons.uptime")
|
|
51
|
+
reason_tps: str = yaml_key("reasons.tps")
|
|
52
|
+
reason_low_uptime: str = yaml_key("reasons.low_uptime")
|
|
53
|
+
reason_players: str = yaml_key("reasons.players")
|
|
54
54
|
|
|
55
55
|
pro_restart_number: str = yaml_key("reasons.pro_restart_number")
|
|
56
56
|
anti_restart_number: str = yaml_key("reasons.anti_restart_number")
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
from dataclasses import dataclass, field
|
|
2
|
+
|
|
3
|
+
def yaml_key(path: str):
|
|
4
|
+
return field(metadata={"yaml_key": path})
|
|
5
|
+
|
|
6
|
+
@dataclass
|
|
7
|
+
class WatcherConfig:
|
|
8
|
+
schedule_control: bool = yaml_key("schedule_control.enabled")
|
|
9
|
+
restart_soon_id: int = yaml_key("schedule_control.restart_soon_id")
|
|
10
|
+
|
|
11
|
+
threshold_ram: int = yaml_key("thresholds.ram")
|
|
12
|
+
threshold_cpu: int = yaml_key("thresholds.cpu")
|
|
13
|
+
threshold_uptime_hours: int = yaml_key("thresholds.uptime")
|
|
14
|
+
threshold_tps: float = yaml_key("thresholds.tps")
|
|
15
|
+
|
|
16
|
+
weight_restart_soon: int = yaml_key("weights.restart_soon")
|
|
17
|
+
weight_ram: int = yaml_key("weights.ram")
|
|
18
|
+
weight_cpu: int = yaml_key("weights.cpu")
|
|
19
|
+
weight_uptime: int = yaml_key("weights.uptime")
|
|
20
|
+
weight_tps: int = yaml_key("weights.tps")
|
|
21
|
+
|
|
22
|
+
weight_low_uptime: int = yaml_key("weights.low_uptime")
|
|
23
|
+
weight_per_player: int = yaml_key("weights.per_player")
|
|
24
|
+
|
|
25
|
+
low_gap_minutes: int = yaml_key("gaps.low_gap_minutes")
|
|
26
|
+
high_gap_minutes: int = yaml_key("gaps.high_gap_minutes")
|
|
27
|
+
|
|
28
|
+
restart_wait_seconds: int = yaml_key("restart.wait_seconds")
|
|
29
|
+
restart_timeout: int = yaml_key("restart.online_timeout")
|
|
30
|
+
restart_online_interval: int = yaml_key("restart.online_interval")
|
|
@@ -60,17 +60,17 @@ def validate_global_config(config, errors):
|
|
|
60
60
|
|
|
61
61
|
|
|
62
62
|
def validate_watcher_config(watcherconfig, errors):
|
|
63
|
-
if watcherconfig.
|
|
64
|
-
errors.append(f"
|
|
63
|
+
if watcherconfig.restart_wait_seconds < 1:
|
|
64
|
+
errors.append(f"restart_wait_seconds: must be >= 1 (got {watcherconfig.restart_wait_seconds})")
|
|
65
65
|
|
|
66
|
-
if watcherconfig.
|
|
67
|
-
errors.append(f"
|
|
66
|
+
if watcherconfig.threshold_cpu <= 0:
|
|
67
|
+
errors.append(f"threshold_cpu: must not be less than 1 (got {watcherconfig.threshold_cpu})")
|
|
68
68
|
|
|
69
|
-
if watcherconfig.
|
|
70
|
-
errors.append(f"
|
|
69
|
+
if watcherconfig.threshold_ram <= 0:
|
|
70
|
+
errors.append(f"threshold_ram: must be > 0 (got {watcherconfig.threshold_ram})")
|
|
71
71
|
|
|
72
|
-
if watcherconfig.
|
|
73
|
-
errors.append(f"
|
|
72
|
+
if watcherconfig.threshold_tps <= 0 or watcherconfig.threshold_tps > 20:
|
|
73
|
+
errors.append(f"threshold_tps: must be 1–20 (got {watcherconfig.threshold_tps})")
|
|
74
74
|
|
|
75
75
|
|
|
76
76
|
def validate_messages_config(messages, errors):
|
|
@@ -97,13 +97,13 @@ class ServerWatcher:
|
|
|
97
97
|
self.origin.disableSchedule(self.watcherconfig.restart_soon_id)
|
|
98
98
|
self.server.restart()
|
|
99
99
|
self.say(self.messages.restart_action_sent)
|
|
100
|
-
time.sleep(self.watcherconfig.
|
|
100
|
+
time.sleep(self.watcherconfig.restart_wait_seconds)
|
|
101
101
|
|
|
102
102
|
self.say(self.messages.log_status_check, level="warn")
|
|
103
103
|
alive = waitForOnline(
|
|
104
104
|
self.server,
|
|
105
|
-
timeout=self.watcherconfig.
|
|
106
|
-
interval=self.watcherconfig.
|
|
105
|
+
timeout=self.watcherconfig.restart_timeout,
|
|
106
|
+
interval=self.watcherconfig.restart_online_interval,
|
|
107
107
|
)
|
|
108
108
|
|
|
109
109
|
if alive:
|
|
@@ -161,37 +161,37 @@ class ServerWatcher:
|
|
|
161
161
|
no_restart_reasons = []
|
|
162
162
|
|
|
163
163
|
if self.watcherconfig.schedule_control and self.server.getSchedule(self.watcherconfig.restart_soon_id)["is_active"]:
|
|
164
|
-
restart_reasons.append(self.messages.
|
|
165
|
-
pro += self.watcherconfig.
|
|
164
|
+
restart_reasons.append(self.messages.reason_restart_soon)
|
|
165
|
+
pro += self.watcherconfig.weight_restart_soon
|
|
166
166
|
|
|
167
|
-
if snap.ram >= self.watcherconfig.
|
|
168
|
-
restart_reasons.append(self.fmt(self.messages.
|
|
169
|
-
pro += int(round(snap.ram, 0) - (self.watcherconfig.
|
|
167
|
+
if snap.ram >= self.watcherconfig.threshold_ram:
|
|
168
|
+
restart_reasons.append(self.fmt(self.messages.reason_ram, ram=snap.ram, threshold=self.watcherconfig.threshold_ram))
|
|
169
|
+
pro += int(round(snap.ram, 0) - (self.watcherconfig.threshold_ram - 1))
|
|
170
170
|
|
|
171
|
-
if snap.cpu >= self.watcherconfig.
|
|
172
|
-
restart_reasons.append(self.fmt(self.messages.
|
|
173
|
-
pro += self.watcherconfig.
|
|
171
|
+
if snap.cpu >= self.watcherconfig.threshold_cpu:
|
|
172
|
+
restart_reasons.append(self.fmt(self.messages.reason_cpu, cpu=snap.cpu, threshold=self.watcherconfig.threshold_cpu))
|
|
173
|
+
pro += self.watcherconfig.weight_cpu
|
|
174
174
|
|
|
175
|
-
if snap.uptime // 3600 >= self.watcherconfig.
|
|
175
|
+
if snap.uptime // 3600 >= self.watcherconfig.threshold_uptime:
|
|
176
176
|
restart_reasons.append(
|
|
177
|
-
self.fmt(self.messages.
|
|
178
|
-
threshold=self.watcherconfig.
|
|
177
|
+
self.fmt(self.messages.reason_uptime, uptime=snap.uptime_formatted,
|
|
178
|
+
threshold=self.watcherconfig.threshold_uptime)
|
|
179
179
|
)
|
|
180
180
|
pro += self.watcherconfig.weight_uptime
|
|
181
181
|
|
|
182
|
-
if (snap.tps if snap.tps is not None else 0) <= self.watcherconfig.
|
|
183
|
-
restart_reasons.append(self.fmt(self.messages.
|
|
184
|
-
pro += self.watcherconfig.
|
|
182
|
+
if (snap.tps if snap.tps is not None else 0) <= self.watcherconfig.threshold_tps:
|
|
183
|
+
restart_reasons.append(self.fmt(self.messages.reason_tps, tps=snap.tps, threshold=self.watcherconfig.threshold_tps))
|
|
184
|
+
pro += self.watcherconfig.weight_tps
|
|
185
185
|
|
|
186
186
|
if snap.uptime // 60 < 30:
|
|
187
|
-
no_restart_reasons.append(self.fmt(self.messages.
|
|
188
|
-
anti += self.watcherconfig.
|
|
187
|
+
no_restart_reasons.append(self.fmt(self.messages.reason_low_uptime, uptime=snap.uptime_formatted))
|
|
188
|
+
anti += self.watcherconfig.weight_low_uptime
|
|
189
189
|
|
|
190
190
|
if snap.players > 0:
|
|
191
191
|
verb = "are" if snap.players != 1 else "is"
|
|
192
192
|
plural = "players" if snap.players != 1 else "player"
|
|
193
|
-
no_restart_reasons.append(self.fmt(self.messages.
|
|
194
|
-
anti += snap.players * self.watcherconfig.
|
|
193
|
+
no_restart_reasons.append(self.fmt(self.messages.reason_players, verb=verb, count=snap.players, plural=plural))
|
|
194
|
+
anti += snap.players * self.watcherconfig.weight_per_player
|
|
195
195
|
|
|
196
196
|
if restart_reasons:
|
|
197
197
|
self.say(self.messages.pro_restart_splash, level="warn")
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
from dataclasses import dataclass, field
|
|
2
|
-
|
|
3
|
-
def yaml_key(path: str):
|
|
4
|
-
return field(metadata={"yaml_key": path})
|
|
5
|
-
|
|
6
|
-
@dataclass
|
|
7
|
-
class WatcherConfig:
|
|
8
|
-
schedule_control: bool = yaml_key("schedule_control.enabled")
|
|
9
|
-
restart_soon_id: int = yaml_key("schedule_control.restart_soon_id")
|
|
10
|
-
|
|
11
|
-
thresholds.ram: int = yaml_key("thresholds.ram")
|
|
12
|
-
thresholds.cpu: int = yaml_key("thresholds.cpu")
|
|
13
|
-
thresholds.uptime_hours: int = yaml_key("thresholds.uptime")
|
|
14
|
-
thresholds.tps: float = yaml_key("thresholds.tps")
|
|
15
|
-
|
|
16
|
-
weights.restart_soon: int = yaml_key("weights.restart_soon")
|
|
17
|
-
weights.ram: int = yaml_key("weights.ram")
|
|
18
|
-
weights.cpu: int = yaml_key("weights.cpu")
|
|
19
|
-
weights.uptime: int = yaml_key("weights.uptime")
|
|
20
|
-
weights.tps: int = yaml_key("weights.tps")
|
|
21
|
-
|
|
22
|
-
weights.low_uptime: int = yaml_key("weights.low_uptime")
|
|
23
|
-
weights.per_player: int = yaml_key("weights.per_player")
|
|
24
|
-
|
|
25
|
-
low_gap_minutes: int = yaml_key("gaps.low_gap_minutes")
|
|
26
|
-
high_gap_minutes: int = yaml_key("gaps.high_gap_minutes")
|
|
27
|
-
|
|
28
|
-
restart.wait_seconds: int = yaml_key("restart.wait_seconds")
|
|
29
|
-
restart.timeout: int = yaml_key("restart.online_timeout")
|
|
30
|
-
restart.online_interval: int = yaml_key("restart.online_interval")
|
|
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
|