serverwatcher 4.6__tar.gz → 4.7.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.
Files changed (21) hide show
  1. {serverwatcher-4.6/src/serverwatcher.egg-info → serverwatcher-4.7.1}/PKG-INFO +1 -1
  2. {serverwatcher-4.6 → serverwatcher-4.7.1}/pyproject.toml +1 -1
  3. {serverwatcher-4.6 → serverwatcher-4.7.1}/src/serverwatcher/configclasses/messages.py +5 -0
  4. serverwatcher-4.7.1/src/serverwatcher/defaultconfigs/global.yaml +28 -0
  5. {serverwatcher-4.6 → serverwatcher-4.7.1}/src/serverwatcher/defaultconfigs/messages.yaml +5 -1
  6. {serverwatcher-4.6 → serverwatcher-4.7.1}/src/serverwatcher/defaultconfigs/watcher.yaml +1 -1
  7. {serverwatcher-4.6 → serverwatcher-4.7.1}/src/serverwatcher/watcher.py +19 -26
  8. {serverwatcher-4.6 → serverwatcher-4.7.1/src/serverwatcher.egg-info}/PKG-INFO +1 -1
  9. serverwatcher-4.6/src/serverwatcher/defaultconfigs/global.yaml +0 -28
  10. {serverwatcher-4.6 → serverwatcher-4.7.1}/LICENSE +0 -0
  11. {serverwatcher-4.6 → serverwatcher-4.7.1}/README.md +0 -0
  12. {serverwatcher-4.6 → serverwatcher-4.7.1}/setup.cfg +0 -0
  13. {serverwatcher-4.6 → serverwatcher-4.7.1}/src/serverwatcher/__init__.py +0 -0
  14. {serverwatcher-4.6 → serverwatcher-4.7.1}/src/serverwatcher/configclasses/__init__.py +0 -0
  15. {serverwatcher-4.6 → serverwatcher-4.7.1}/src/serverwatcher/configclasses/global_config.py +0 -0
  16. {serverwatcher-4.6 → serverwatcher-4.7.1}/src/serverwatcher/configclasses/watcher.py +0 -0
  17. {serverwatcher-4.6 → serverwatcher-4.7.1}/src/serverwatcher/validator.py +0 -0
  18. {serverwatcher-4.6 → serverwatcher-4.7.1}/src/serverwatcher.egg-info/SOURCES.txt +0 -0
  19. {serverwatcher-4.6 → serverwatcher-4.7.1}/src/serverwatcher.egg-info/dependency_links.txt +0 -0
  20. {serverwatcher-4.6 → serverwatcher-4.7.1}/src/serverwatcher.egg-info/requires.txt +0 -0
  21. {serverwatcher-4.6 → serverwatcher-4.7.1}/src/serverwatcher.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: serverwatcher
3
- Version: 4.6
3
+ Version: 4.7.1
4
4
  Summary: A HungerLib-powered Minecraft server automation engine.
5
5
  Author: iFamished
6
6
  License: GPL-3.0
@@ -7,7 +7,7 @@ build-backend = "setuptools.build_meta"
7
7
 
8
8
  [project]
9
9
  name = "serverwatcher"
10
- version = "4.6"
10
+ version = "4.7.1"
11
11
  description = "A HungerLib-powered Minecraft server automation engine."
12
12
  readme = "README.md"
13
13
  requires-python = ">=3.10"
@@ -4,7 +4,9 @@ from dataclasses import dataclass, field
4
4
  @dataclass
5
5
  class MessagesConfig:
6
6
  prefix: str
7
+
7
8
  broadcast_restart_at: str
9
+ bullet: str
8
10
 
9
11
  # minute messages
10
12
  minute_120: str
@@ -40,6 +42,9 @@ class MessagesConfig:
40
42
  log_gap_high: str
41
43
 
42
44
  # reasons
45
+ pro_restart_splash: str
46
+ anti_restart_splash: str
47
+
43
48
  reason_restart_soon: str
44
49
  reason_ram: str
45
50
  reason_cpu: str
@@ -0,0 +1,28 @@
1
+ watch_interval: 300
2
+
3
+ panel:
4
+ panel_name: "My Panel"
5
+ panel_url: "https://example.com"
6
+ panel_api_key: "CHANGE_ME"
7
+
8
+ origin:
9
+ origin_server_id: "CHANGE_ME"
10
+
11
+ server:
12
+ server_name: "My SMP"
13
+ server_id: "CHANGE_ME"
14
+ server_domain: "mc.example.com"
15
+ server_port: 25565
16
+ rcon_port: 25575
17
+ rcon_password: "password"
18
+ tps_command: "ticks"
19
+
20
+ logging:
21
+ do_logging: True
22
+ logger_name: "Server Watcher"
23
+ log_path: "/home/container/logs/"
24
+ timezone: "America/Chicago"
25
+
26
+ terminal:
27
+ console_backspaces: 8
28
+ clear_terminal: True
@@ -1,6 +1,7 @@
1
- prefix: "<aqua>[Server Watcher]"
1
+ prefix: "<reset><aqua>[Server Watcher]"
2
2
 
3
3
  broadcast_restart_at: "{prefix} The server will restart at {time} CDT."
4
+ bullet: "-"
4
5
 
5
6
  broadcast_minute:
6
7
  minute_120: "{prefix} Restart in 2 hours!"
@@ -36,6 +37,9 @@ logging:
36
37
  log_gap_high: "Gap {gap}. Scheduling restart in 1 hour."
37
38
 
38
39
  reasons:
40
+ pro_restart_splash: "PRO-RESTART REASONS:"
41
+ anti_restart_splash: "ANTI-RESTART REASONS:"
42
+
39
43
  reason_restart_soon: "The server is set to restart soon"
40
44
  reason_ram: "RAM usage ({ram}) is higher than {threshold} GB"
41
45
  reason_cpu: "CPU usage ({cpu}) is higher than {threshold}%"
@@ -22,6 +22,6 @@ gaps:
22
22
  high_gap_minutes: 60
23
23
 
24
24
  restart_intervals:
25
- restart_wait_seconds: 45
25
+ restart_wait_seconds: 30
26
26
  restart_online_timeout: 120
27
27
  restart_online_interval: 2
@@ -18,7 +18,6 @@ from serverwatcher.configclasses.global_config import GlobalConfig
18
18
  from serverwatcher.configclasses.messages import MessagesConfig
19
19
  from serverwatcher.configclasses.watcher import WatcherConfig
20
20
 
21
-
22
21
  from serverwatcher.validator import validate_all
23
22
 
24
23
  validate_all()
@@ -107,7 +106,7 @@ class ServerWatcher:
107
106
 
108
107
  if alive:
109
108
  self.log.info(self.messages.server_back_online)
110
- self.server.sendBroadcast(f"{self.messages.server_back_online_broadcast}")
109
+ self.log.info(self.fmt(self.messages.server_back_online_broadcast), destination=True, origin=False, logs=False)
111
110
  else:
112
111
  self.log.error(self.messages.server_failed_restart)
113
112
 
@@ -119,9 +118,7 @@ class ServerWatcher:
119
118
  local_time = scheduled.astimezone(self.tz)
120
119
  time_str = local_time.strftime("%I:%M %p")
121
120
 
122
- self.server.sendBroadcast(
123
- self.fmt(self.messages.broadcast_restart_at, time=time_str)
124
- )
121
+ self.server.sendBroadcast(self.fmt(self.messages.broadcast_restart_at, time=time_str))
125
122
 
126
123
  # minute_* callbacks
127
124
  minute_callbacks = {
@@ -171,15 +168,11 @@ class ServerWatcher:
171
168
  pro += self.cfg.weight_restart_soon
172
169
 
173
170
  if snap.ram >= self.cfg.ram_threshold:
174
- restart_reasons.append(
175
- self.fmt(self.messages.reason_ram, ram=snap.ram, threshold=self.cfg.ram_threshold)
176
- )
171
+ restart_reasons.append(self.fmt(self.messages.reason_ram, ram=snap.ram, threshold=self.cfg.ram_threshold))
177
172
  pro += int(round(snap.ram, 0) - (self.cfg.ram_threshold - 1))
178
173
 
179
174
  if snap.cpu >= self.cfg.cpu_threshold:
180
- restart_reasons.append(
181
- self.fmt(self.messages.reason_cpu, cpu=snap.cpu, threshold=self.cfg.cpu_threshold)
182
- )
175
+ restart_reasons.append(self.fmt(self.messages.reason_cpu, cpu=snap.cpu, threshold=self.cfg.cpu_threshold))
183
176
  pro += self.cfg.weight_cpu
184
177
 
185
178
  if snap.uptime // 3600 >= self.cfg.uptime_hours_threshold:
@@ -189,32 +182,33 @@ class ServerWatcher:
189
182
  )
190
183
  pro += self.cfg.weight_uptime
191
184
 
192
- if snap.tps <= self.cfg.tps_threshold:
193
- restart_reasons.append(
194
- self.fmt(self.messages.reason_tps, tps=snap.tps, threshold=self.cfg.tps_threshold)
195
- )
185
+ if (snap.tps if snap.tps is not None else 0) <= self.cfg.tps_threshold:
186
+ restart_reasons.append(self.fmt(self.messages.reason_tps, tps=snap.tps, threshold=self.cfg.tps_threshold))
196
187
  pro += self.cfg.weight_tps
197
188
 
198
189
  # anti-restart
199
190
  if snap.uptime // 60 < 30:
200
- no_restart_reasons.append(
201
- self.fmt(self.messages.reason_low_uptime, uptime=snap.uptime_formatted)
202
- )
191
+ no_restart_reasons.append(self.fmt(self.messages.reason_low_uptime, uptime=snap.uptime_formatted))
203
192
  anti += self.cfg.weight_low_uptime
204
193
 
205
194
  if snap.players > 0:
206
195
  verb = "are" if snap.players != 1 else "is"
207
196
  plural = "players" if snap.players != 1 else "player"
208
- no_restart_reasons.append(
209
- self.fmt(self.messages.reason_players, verb=verb, count=snap.players, plural=plural)
210
- )
197
+ no_restart_reasons.append(self.fmt(self.messages.reason_players, verb=verb, count=snap.players, plural=plural))
211
198
  anti += snap.players * self.cfg.weight_per_player
212
199
 
213
200
  # logging
214
- for r in restart_reasons:
215
- self.log.warn(f"- {r}")
216
- for r in no_restart_reasons:
217
- self.log.warn(f"- {r}")
201
+ if restart_reasons:
202
+ self.log.warn(f"{self.messages.pro_restart_splash}")
203
+ for r in restart_reasons:
204
+ self.log.warn(f"- {r}")
205
+ self.log.warn("\n")
206
+
207
+ if no_restart_reasons:
208
+ self.log.warn(f"{self.messages.anti_restart_splash}")
209
+ for r in no_restart_reasons:
210
+ self.log.warn(f"{self.messages.bullet} {r}")
211
+ self.log.warn("\n")
218
212
 
219
213
  self.log.warn(f"Pro-restart: {pro}")
220
214
  self.log.warn(f"Anti-restart: {anti}")
@@ -236,7 +230,6 @@ class ServerWatcher:
236
230
  if gap <= 2:
237
231
  self.log.warn(self.fmt(self.messages.log_gap_low, gap=gap))
238
232
  self.schedule_restart(self.cfg.low_gap_minutes)
239
- else:
240
233
  self.log.warn(self.fmt(self.messages.log_gap_high, gap=gap))
241
234
  self.schedule_restart(self.cfg.high_gap_minutes)
242
235
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: serverwatcher
3
- Version: 4.6
3
+ Version: 4.7.1
4
4
  Summary: A HungerLib-powered Minecraft server automation engine.
5
5
  Author: iFamished
6
6
  License: GPL-3.0
@@ -1,28 +0,0 @@
1
- watch_interval: 60
2
-
3
- panel:
4
- panel_name: My Panel
5
- panel_url: https://example.com
6
- panel_api_key: CHANGE_ME
7
-
8
- origin:
9
- origin_server_id: CHANGE_ME
10
-
11
- server:
12
- server_name: My SMP
13
- server_id: CHANGE_ME
14
- server_domain: mc.example.com
15
- server_port: 25565
16
- rcon_port: 25575
17
- rcon_password: password
18
- tps_command: ticks
19
-
20
- logging:
21
- do_logging: True
22
- logger_name: "Server Watcher"
23
- log_path: "/home/container/logs/"
24
- timezone: "America/Chicago"
25
-
26
- terminal:
27
- console_backspaces: 8
28
- clear_terminal: True
File without changes
File without changes
File without changes