serverwatcher 4.8__tar.gz → 5.0__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-4.8/src/serverwatcher.egg-info → serverwatcher-5.0}/PKG-INFO +1 -1
- {serverwatcher-4.8 → serverwatcher-5.0}/pyproject.toml +1 -1
- serverwatcher-5.0/src/serverwatcher/configclasses/global_config.py +30 -0
- serverwatcher-5.0/src/serverwatcher/configclasses/messages.py +65 -0
- serverwatcher-5.0/src/serverwatcher/configclasses/watcher.py +30 -0
- {serverwatcher-4.8 → serverwatcher-5.0}/src/serverwatcher/defaultconfigs/messages.yaml +3 -0
- {serverwatcher-4.8 → serverwatcher-5.0}/src/serverwatcher/watcher.py +6 -6
- {serverwatcher-4.8 → serverwatcher-5.0/src/serverwatcher.egg-info}/PKG-INFO +1 -1
- serverwatcher-4.8/src/serverwatcher/configclasses/global_config.py +0 -27
- serverwatcher-4.8/src/serverwatcher/configclasses/messages.py +0 -60
- serverwatcher-4.8/src/serverwatcher/configclasses/watcher.py +0 -27
- {serverwatcher-4.8 → serverwatcher-5.0}/LICENSE +0 -0
- {serverwatcher-4.8 → serverwatcher-5.0}/README.md +0 -0
- {serverwatcher-4.8 → serverwatcher-5.0}/setup.cfg +0 -0
- {serverwatcher-4.8 → serverwatcher-5.0}/src/serverwatcher/__init__.py +0 -0
- {serverwatcher-4.8 → serverwatcher-5.0}/src/serverwatcher/configclasses/__init__.py +0 -0
- {serverwatcher-4.8 → serverwatcher-5.0}/src/serverwatcher/defaultconfigs/global.yaml +0 -0
- {serverwatcher-4.8 → serverwatcher-5.0}/src/serverwatcher/defaultconfigs/watcher.yaml +0 -0
- {serverwatcher-4.8 → serverwatcher-5.0}/src/serverwatcher/validator.py +0 -0
- {serverwatcher-4.8 → serverwatcher-5.0}/src/serverwatcher.egg-info/SOURCES.txt +0 -0
- {serverwatcher-4.8 → serverwatcher-5.0}/src/serverwatcher.egg-info/dependency_links.txt +0 -0
- {serverwatcher-4.8 → serverwatcher-5.0}/src/serverwatcher.egg-info/requires.txt +0 -0
- {serverwatcher-4.8 → serverwatcher-5.0}/src/serverwatcher.egg-info/top_level.txt +0 -0
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
from dataclasses import dataclass, field
|
|
2
|
+
|
|
3
|
+
def yaml_key(name: str):
|
|
4
|
+
return field(metadata={"yaml_key": name})
|
|
5
|
+
|
|
6
|
+
@dataclass
|
|
7
|
+
class GlobalConfig:
|
|
8
|
+
watch_interval: int = yaml_key("watch_interval")
|
|
9
|
+
|
|
10
|
+
panel_name: str = yaml_key("panel_name")
|
|
11
|
+
panel_url: str = yaml_key("panel_url")
|
|
12
|
+
panel_api_key: str = yaml_key("panel_api_key")
|
|
13
|
+
|
|
14
|
+
origin_server_id: str = yaml_key("origin_server_id")
|
|
15
|
+
|
|
16
|
+
server_name: str = yaml_key("server_name")
|
|
17
|
+
server_id: str = yaml_key("server_id")
|
|
18
|
+
server_domain: str = yaml_key("server_domain")
|
|
19
|
+
server_port: int = yaml_key("server_port")
|
|
20
|
+
rcon_port: int = yaml_key("rcon_port")
|
|
21
|
+
rcon_password: str = yaml_key("rcon_password")
|
|
22
|
+
tps_command: str = yaml_key("tps_command")
|
|
23
|
+
|
|
24
|
+
do_logging: bool = yaml_key("do_logging")
|
|
25
|
+
logger_name: str = yaml_key("logger_name")
|
|
26
|
+
log_path: str = yaml_key("log_path")
|
|
27
|
+
timezone: str = yaml_key("timezone")
|
|
28
|
+
|
|
29
|
+
console_backspaces: int = yaml_key("console_backspaces")
|
|
30
|
+
clear_terminal: bool = yaml_key("clear_terminal")
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
from dataclasses import dataclass, field
|
|
2
|
+
|
|
3
|
+
def yaml_key(name: str):
|
|
4
|
+
return field(metadata={"yaml_key": name})
|
|
5
|
+
|
|
6
|
+
@dataclass
|
|
7
|
+
class MessagesConfig:
|
|
8
|
+
prefix: str = yaml_key("prefix")
|
|
9
|
+
|
|
10
|
+
broadcast_restart_at: str = yaml_key("broadcast_restart_at")
|
|
11
|
+
bullet: str = yaml_key("bullet")
|
|
12
|
+
|
|
13
|
+
# minute messages
|
|
14
|
+
minute_120: str = yaml_key("minute_120")
|
|
15
|
+
minute_60: str = yaml_key("minute_60")
|
|
16
|
+
minute_45: str = yaml_key("minute_45")
|
|
17
|
+
minute_30: str = yaml_key("minute_30")
|
|
18
|
+
minute_15: str = yaml_key("minute_15")
|
|
19
|
+
minute_5: str = yaml_key("minute_5")
|
|
20
|
+
minute_1: str = yaml_key("minute_1")
|
|
21
|
+
|
|
22
|
+
# second messages
|
|
23
|
+
second_10: str = yaml_key("second_10")
|
|
24
|
+
second_9: str = yaml_key("second_9")
|
|
25
|
+
second_8: str = yaml_key("second_8")
|
|
26
|
+
second_7: str = yaml_key("second_7")
|
|
27
|
+
second_6: str = yaml_key("second_6")
|
|
28
|
+
second_5: str = yaml_key("second_5")
|
|
29
|
+
second_4: str = yaml_key("second_4")
|
|
30
|
+
second_3: str = yaml_key("second_3")
|
|
31
|
+
second_2: str = yaml_key("second_2")
|
|
32
|
+
second_1: str = yaml_key("second_1")
|
|
33
|
+
|
|
34
|
+
# logging
|
|
35
|
+
log_start: str = yaml_key("log_start")
|
|
36
|
+
log_status_check: str = yaml_key("log_status_check")
|
|
37
|
+
log_validation_fail: str = yaml_key("log_validation_fail")
|
|
38
|
+
log_validation_ok: str = yaml_key("log_validation_ok")
|
|
39
|
+
log_shutdown: str = yaml_key("log_shutdown")
|
|
40
|
+
log_immediate_restart: str = yaml_key("log_immediate_restart")
|
|
41
|
+
log_no_restart: str = yaml_key("log_no_restart")
|
|
42
|
+
log_scheduled: str = yaml_key("log_scheduled")
|
|
43
|
+
log_gap_low: str = yaml_key("log_gap_low")
|
|
44
|
+
log_gap_high: str = yaml_key("log_gap_high")
|
|
45
|
+
|
|
46
|
+
# reasons
|
|
47
|
+
pro_restart_splash: str = yaml_key("pro_restart_splash")
|
|
48
|
+
anti_restart_splash: str = yaml_key("anti_restart_splash")
|
|
49
|
+
|
|
50
|
+
reason_restart_soon: str = yaml_key("reason_restart_soon")
|
|
51
|
+
reason_ram: str = yaml_key("reason_ram")
|
|
52
|
+
reason_cpu: str = yaml_key("reason_cpu")
|
|
53
|
+
reason_uptime: str = yaml_key("reason_uptime")
|
|
54
|
+
reason_tps: str = yaml_key("reason_tps")
|
|
55
|
+
reason_low_uptime: str = yaml_key("reason_low_uptime")
|
|
56
|
+
reason_players: str = yaml_key("reason_players")
|
|
57
|
+
|
|
58
|
+
pro_restart_number: str = yaml_key("pro_restart_number")
|
|
59
|
+
anti_restart_number: str = yaml_key("anti_restart_number")
|
|
60
|
+
|
|
61
|
+
# restarts
|
|
62
|
+
restart_action_sent: str = yaml_key("restart_action_sent")
|
|
63
|
+
server_back_online: str = yaml_key("server_back_online")
|
|
64
|
+
server_back_online_broadcast: str = yaml_key("server_back_online_broadcast")
|
|
65
|
+
server_failed_restart: str = yaml_key("server_failed_restart")
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
from dataclasses import dataclass, field
|
|
2
|
+
|
|
3
|
+
def yaml_key(name: str):
|
|
4
|
+
return field(metadata={"yaml_key": name})
|
|
5
|
+
|
|
6
|
+
@dataclass
|
|
7
|
+
class WatcherConfig:
|
|
8
|
+
schedule_control: bool = yaml_key("schedule_control")
|
|
9
|
+
restart_soon_id: int = yaml_key("restart_soon_id")
|
|
10
|
+
|
|
11
|
+
ram_threshold: int = yaml_key("ram_threshold")
|
|
12
|
+
cpu_threshold: int = yaml_key("cpu_threshold")
|
|
13
|
+
uptime_hours_threshold: int = yaml_key("uptime_hours_threshold")
|
|
14
|
+
tps_threshold: float = yaml_key("tps_threshold")
|
|
15
|
+
|
|
16
|
+
weight_restart_soon: int = yaml_key("weight_restart_soon")
|
|
17
|
+
weight_ram: int = yaml_key("weight_ram")
|
|
18
|
+
weight_cpu: int = yaml_key("weight_cpu")
|
|
19
|
+
weight_uptime: int = yaml_key("weight_uptime")
|
|
20
|
+
weight_tps: int = yaml_key("weight_tps")
|
|
21
|
+
|
|
22
|
+
weight_low_uptime: int = yaml_key("weight_low_uptime")
|
|
23
|
+
weight_per_player: int = yaml_key("weight_per_player")
|
|
24
|
+
|
|
25
|
+
low_gap_minutes: int = yaml_key("low_gap_minutes")
|
|
26
|
+
high_gap_minutes: int = yaml_key("high_gap_minutes")
|
|
27
|
+
|
|
28
|
+
restart_wait_seconds: int = yaml_key("restart_wait_seconds")
|
|
29
|
+
restart_online_timeout: int = yaml_key("restart_online_timeout")
|
|
30
|
+
restart_online_interval: int = yaml_key("restart_online_interval")
|
|
@@ -48,6 +48,9 @@ reasons:
|
|
|
48
48
|
reason_low_uptime: "Uptime {uptime} is shorter than 30m"
|
|
49
49
|
reason_players: "There {verb} {count} {plural} online"
|
|
50
50
|
|
|
51
|
+
pro_restart_number: "Pro-restart: "
|
|
52
|
+
anti_restart_number: "Anti-restart:"
|
|
53
|
+
|
|
51
54
|
restarts:
|
|
52
55
|
restart_action_sent: "Restart action sent. Waiting..."
|
|
53
56
|
server_back_online: "Server is back online!"
|
|
@@ -82,10 +82,10 @@ class ServerWatcher:
|
|
|
82
82
|
def fmt(self, template: str, **kwargs):
|
|
83
83
|
return template.format(prefix=self.messages.prefix, **kwargs)
|
|
84
84
|
|
|
85
|
-
def say(self,
|
|
86
|
-
if not
|
|
85
|
+
def say(self, key, level="info", **fmt):
|
|
86
|
+
if not key:
|
|
87
87
|
return
|
|
88
|
-
text = self.fmt(
|
|
88
|
+
text = self.fmt(key, **fmt)
|
|
89
89
|
getattr(self.log, level)(text)
|
|
90
90
|
|
|
91
91
|
def shutdown(self):
|
|
@@ -196,7 +196,7 @@ class ServerWatcher:
|
|
|
196
196
|
if restart_reasons:
|
|
197
197
|
self.say(self.messages.pro_restart_splash, level="warn")
|
|
198
198
|
for r in restart_reasons:
|
|
199
|
-
self.log.warn(f"
|
|
199
|
+
self.log.warn(f"{self.messages.bullet} {r}")
|
|
200
200
|
self.log.warn("\n")
|
|
201
201
|
|
|
202
202
|
if no_restart_reasons:
|
|
@@ -205,8 +205,8 @@ class ServerWatcher:
|
|
|
205
205
|
self.log.warn(f"{self.messages.bullet} {r}")
|
|
206
206
|
self.log.warn("\n")
|
|
207
207
|
|
|
208
|
-
self.log.warn(f"
|
|
209
|
-
self.log.warn(f"
|
|
208
|
+
self.log.warn(f"{self.messages.pro_restart_number} {pro}")
|
|
209
|
+
self.log.warn(f"{self.messages.anti_restart_number} {anti}")
|
|
210
210
|
|
|
211
211
|
gap = abs(pro - anti)
|
|
212
212
|
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
from dataclasses import dataclass
|
|
2
|
-
|
|
3
|
-
@dataclass
|
|
4
|
-
class GlobalConfig:
|
|
5
|
-
watch_interval: int
|
|
6
|
-
|
|
7
|
-
panel_name: str
|
|
8
|
-
panel_url: str
|
|
9
|
-
panel_api_key: str
|
|
10
|
-
|
|
11
|
-
origin_server_id: str
|
|
12
|
-
|
|
13
|
-
server_name: str
|
|
14
|
-
server_id: str
|
|
15
|
-
server_domain: str
|
|
16
|
-
server_port: int
|
|
17
|
-
rcon_port: int
|
|
18
|
-
rcon_password: str
|
|
19
|
-
tps_command: str
|
|
20
|
-
|
|
21
|
-
do_logging: bool
|
|
22
|
-
logger_name: str
|
|
23
|
-
log_path: str
|
|
24
|
-
timezone: str
|
|
25
|
-
|
|
26
|
-
console_backspaces: int
|
|
27
|
-
clear_terminal: bool
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
from dataclasses import dataclass, field
|
|
2
|
-
|
|
3
|
-
@dataclass
|
|
4
|
-
@dataclass
|
|
5
|
-
class MessagesConfig:
|
|
6
|
-
prefix: str
|
|
7
|
-
|
|
8
|
-
broadcast_restart_at: str
|
|
9
|
-
bullet: str
|
|
10
|
-
|
|
11
|
-
# minute messages
|
|
12
|
-
minute_120: str
|
|
13
|
-
minute_60: str
|
|
14
|
-
minute_45: str
|
|
15
|
-
minute_30: str
|
|
16
|
-
minute_15: str
|
|
17
|
-
minute_5: str
|
|
18
|
-
minute_1: str
|
|
19
|
-
|
|
20
|
-
# second messages
|
|
21
|
-
second_10: str
|
|
22
|
-
second_9: str
|
|
23
|
-
second_8: str
|
|
24
|
-
second_7: str
|
|
25
|
-
second_6: str
|
|
26
|
-
second_5: str
|
|
27
|
-
second_4: str
|
|
28
|
-
second_3: str
|
|
29
|
-
second_2: str
|
|
30
|
-
second_1: str
|
|
31
|
-
|
|
32
|
-
# logging
|
|
33
|
-
log_start: str
|
|
34
|
-
log_status_check: str
|
|
35
|
-
log_validation_fail: str
|
|
36
|
-
log_validation_ok: str
|
|
37
|
-
log_shutdown: str
|
|
38
|
-
log_immediate_restart: str
|
|
39
|
-
log_no_restart: str
|
|
40
|
-
log_scheduled: str
|
|
41
|
-
log_gap_low: str
|
|
42
|
-
log_gap_high: str
|
|
43
|
-
|
|
44
|
-
# reasons
|
|
45
|
-
pro_restart_splash: str
|
|
46
|
-
anti_restart_splash: str
|
|
47
|
-
|
|
48
|
-
reason_restart_soon: str
|
|
49
|
-
reason_ram: str
|
|
50
|
-
reason_cpu: str
|
|
51
|
-
reason_uptime: str
|
|
52
|
-
reason_tps: str
|
|
53
|
-
reason_low_uptime: str
|
|
54
|
-
reason_players: str
|
|
55
|
-
|
|
56
|
-
# restarts
|
|
57
|
-
restart_action_sent: str
|
|
58
|
-
server_back_online: str
|
|
59
|
-
server_back_online_broadcast: str
|
|
60
|
-
server_failed_restart: str
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
from dataclasses import dataclass
|
|
2
|
-
|
|
3
|
-
@dataclass
|
|
4
|
-
class WatcherConfig:
|
|
5
|
-
schedule_control: bool
|
|
6
|
-
restart_soon_id: int
|
|
7
|
-
|
|
8
|
-
ram_threshold: int
|
|
9
|
-
cpu_threshold: int
|
|
10
|
-
uptime_hours_threshold: int
|
|
11
|
-
tps_threshold: float
|
|
12
|
-
|
|
13
|
-
weight_restart_soon: int
|
|
14
|
-
weight_ram: int
|
|
15
|
-
weight_cpu: int
|
|
16
|
-
weight_uptime: int
|
|
17
|
-
weight_tps: int
|
|
18
|
-
|
|
19
|
-
weight_low_uptime: int
|
|
20
|
-
weight_per_player: int
|
|
21
|
-
|
|
22
|
-
low_gap_minutes: int
|
|
23
|
-
high_gap_minutes: int
|
|
24
|
-
|
|
25
|
-
restart_wait_seconds: int
|
|
26
|
-
restart_online_timeout: int
|
|
27
|
-
restart_online_interval: int
|
|
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
|