serverwatcher 1.dev8__tar.gz → 1.dev10__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-1.dev8/src/serverwatcher.egg-info → serverwatcher-1.dev10}/PKG-INFO +2 -2
- {serverwatcher-1.dev8 → serverwatcher-1.dev10}/README.md +1 -1
- {serverwatcher-1.dev8 → serverwatcher-1.dev10}/pyproject.toml +1 -1
- {serverwatcher-1.dev8 → serverwatcher-1.dev10}/src/serverwatcher/actionperformer.py +14 -14
- {serverwatcher-1.dev8 → serverwatcher-1.dev10}/src/serverwatcher/app.py +10 -3
- {serverwatcher-1.dev8 → serverwatcher-1.dev10}/src/serverwatcher/configclasses/evaluation.py +0 -2
- serverwatcher-1.dev10/src/serverwatcher/configclasses/logging.py +20 -0
- {serverwatcher-1.dev8 → serverwatcher-1.dev10}/src/serverwatcher/configclasses/messages.py +11 -19
- {serverwatcher-1.dev8 → serverwatcher-1.dev10}/src/serverwatcher/defaultconfigs/config.yaml +0 -11
- {serverwatcher-1.dev8 → serverwatcher-1.dev10}/src/serverwatcher/defaultconfigs/evaluation.yaml +1 -3
- serverwatcher-1.dev10/src/serverwatcher/defaultconfigs/logging.yaml +16 -0
- {serverwatcher-1.dev8 → serverwatcher-1.dev10}/src/serverwatcher/defaultconfigs/messages.yaml +15 -24
- {serverwatcher-1.dev8 → serverwatcher-1.dev10}/src/serverwatcher/evaluator.py +12 -2
- {serverwatcher-1.dev8 → serverwatcher-1.dev10}/src/serverwatcher/metricfetcher.py +0 -3
- {serverwatcher-1.dev8 → serverwatcher-1.dev10}/src/serverwatcher/router.py +5 -2
- {serverwatcher-1.dev8 → serverwatcher-1.dev10}/src/serverwatcher/settings.py +1 -1
- {serverwatcher-1.dev8 → serverwatcher-1.dev10/src/serverwatcher.egg-info}/PKG-INFO +2 -2
- {serverwatcher-1.dev8 → serverwatcher-1.dev10}/src/serverwatcher.egg-info/SOURCES.txt +1 -0
- serverwatcher-1.dev8/src/serverwatcher/configclasses/logging.py +0 -15
- {serverwatcher-1.dev8 → serverwatcher-1.dev10}/LICENSE +0 -0
- {serverwatcher-1.dev8 → serverwatcher-1.dev10}/setup.cfg +0 -0
- {serverwatcher-1.dev8 → serverwatcher-1.dev10}/src/old/__init__.py +0 -0
- {serverwatcher-1.dev8 → serverwatcher-1.dev10}/src/old/__main__.py +0 -0
- {serverwatcher-1.dev8 → serverwatcher-1.dev10}/src/old/actionperformer.py +0 -0
- {serverwatcher-1.dev8 → serverwatcher-1.dev10}/src/old/configclasses/__init__.py +0 -0
- {serverwatcher-1.dev8 → serverwatcher-1.dev10}/src/old/configclasses/config.py +0 -0
- {serverwatcher-1.dev8 → serverwatcher-1.dev10}/src/old/configclasses/discord.py +0 -0
- {serverwatcher-1.dev8 → serverwatcher-1.dev10}/src/old/configclasses/environment.py +0 -0
- {serverwatcher-1.dev8 → serverwatcher-1.dev10}/src/old/configclasses/evaluation.py +0 -0
- {serverwatcher-1.dev8 → serverwatcher-1.dev10}/src/old/configclasses/messages.py +0 -0
- {serverwatcher-1.dev8 → serverwatcher-1.dev10}/src/old/configclasses/watcher.py +0 -0
- {serverwatcher-1.dev8 → serverwatcher-1.dev10}/src/old/configmanager.py +0 -0
- {serverwatcher-1.dev8 → serverwatcher-1.dev10}/src/old/evaluator.py +0 -0
- {serverwatcher-1.dev8 → serverwatcher-1.dev10}/src/old/exceptions.py +0 -0
- {serverwatcher-1.dev8 → serverwatcher-1.dev10}/src/old/metricfetcher.py +0 -0
- {serverwatcher-1.dev8 → serverwatcher-1.dev10}/src/old/router.py +0 -0
- {serverwatcher-1.dev8 → serverwatcher-1.dev10}/src/old/targetserver.py +0 -0
- {serverwatcher-1.dev8 → serverwatcher-1.dev10}/src/old/watcher.py +0 -0
- {serverwatcher-1.dev8 → serverwatcher-1.dev10}/src/serverwatcher/__init__.py +0 -0
- {serverwatcher-1.dev8 → serverwatcher-1.dev10}/src/serverwatcher/__main__.py +0 -0
- {serverwatcher-1.dev8 → serverwatcher-1.dev10}/src/serverwatcher/configclasses/__init__.py +0 -0
- {serverwatcher-1.dev8 → serverwatcher-1.dev10}/src/serverwatcher/configclasses/config.py +0 -0
- {serverwatcher-1.dev8 → serverwatcher-1.dev10}/src/serverwatcher/configclasses/watcher.py +0 -0
- {serverwatcher-1.dev8 → serverwatcher-1.dev10}/src/serverwatcher/connection.py +0 -0
- {serverwatcher-1.dev8 → serverwatcher-1.dev10}/src/serverwatcher/defaultconfigs/watcher.yaml +0 -0
- {serverwatcher-1.dev8 → serverwatcher-1.dev10}/src/serverwatcher.egg-info/dependency_links.txt +0 -0
- {serverwatcher-1.dev8 → serverwatcher-1.dev10}/src/serverwatcher.egg-info/entry_points.txt +0 -0
- {serverwatcher-1.dev8 → serverwatcher-1.dev10}/src/serverwatcher.egg-info/requires.txt +0 -0
- {serverwatcher-1.dev8 → serverwatcher-1.dev10}/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: 1.
|
|
3
|
+
Version: 1.dev10
|
|
4
4
|
Summary: A HungerCore-powered Minecraft server automation engine.
|
|
5
5
|
Author: iFamished
|
|
6
6
|
License: GPL-3.0
|
|
@@ -63,7 +63,7 @@ The egg defaults to the `main` branch and enables startup auto-updates. Set `AUT
|
|
|
63
63
|
|
|
64
64
|
`HUNGERLIB_DEV`, `MAPRES_DEV`, and `C2E_DEV` each upgrade their package to the latest prerelease with `uv` on every startup; C2E is optional and is not required by ServerWatcher itself. Choose the ServerWatcher source branch with `GIT_BRANCH`.
|
|
65
65
|
|
|
66
|
-
The YAML files in `src/serverwatcher/defaultconfigs/` are the
|
|
66
|
+
The YAML files in `src/serverwatcher/defaultconfigs/` are the packaged defaults. MapRes copies each one into `/home/container/config/` on first startup and fills missing keys with defaults without replacing overrides. The runtime files are not committed as duplicate defaults: `config.yaml` contains server/API/webhook settings, `logging.yaml` contains logging and terminal settings, and `evaluation.yaml`, `messages.yaml`, and `watcher.yaml` contain their matching settings. `SERVERWATCHER_CONFIG_DIR` can override this path for non-container installs.
|
|
67
67
|
|
|
68
68
|
## HungerNet Bot Webhook
|
|
69
69
|
Set `hungernetbot.enabled` to `True`, `hungernetbot.url` to the Bot's `/webhook` endpoint, and `hungernetbot.token` to the same secret configured as `BRIDGE_WEBHOOK_TOKEN` in HungerNet Bot. For example:
|
|
@@ -32,7 +32,7 @@ The egg defaults to the `main` branch and enables startup auto-updates. Set `AUT
|
|
|
32
32
|
|
|
33
33
|
`HUNGERLIB_DEV`, `MAPRES_DEV`, and `C2E_DEV` each upgrade their package to the latest prerelease with `uv` on every startup; C2E is optional and is not required by ServerWatcher itself. Choose the ServerWatcher source branch with `GIT_BRANCH`.
|
|
34
34
|
|
|
35
|
-
The YAML files in `src/serverwatcher/defaultconfigs/` are the
|
|
35
|
+
The YAML files in `src/serverwatcher/defaultconfigs/` are the packaged defaults. MapRes copies each one into `/home/container/config/` on first startup and fills missing keys with defaults without replacing overrides. The runtime files are not committed as duplicate defaults: `config.yaml` contains server/API/webhook settings, `logging.yaml` contains logging and terminal settings, and `evaluation.yaml`, `messages.yaml`, and `watcher.yaml` contain their matching settings. `SERVERWATCHER_CONFIG_DIR` can override this path for non-container installs.
|
|
36
36
|
|
|
37
37
|
## HungerNet Bot Webhook
|
|
38
38
|
Set `hungernetbot.enabled` to `True`, `hungernetbot.url` to the Bot's `/webhook` endpoint, and `hungernetbot.token` to the same secret configured as `BRIDGE_WEBHOOK_TOKEN` in HungerNet Bot. For example:
|
|
@@ -28,15 +28,15 @@ class ActionPerformer:
|
|
|
28
28
|
return self.scheduleRestart(minutes)
|
|
29
29
|
|
|
30
30
|
if action == 'none':
|
|
31
|
-
self.router.info(
|
|
31
|
+
self.router.info(self.router.messages.no_restart)
|
|
32
32
|
return True
|
|
33
33
|
|
|
34
34
|
raise ValueError('Unknown action: ' + str(action))
|
|
35
35
|
|
|
36
36
|
def restartNow(self):
|
|
37
|
-
self.router.info(
|
|
37
|
+
self.router.info(self.router.messages.immediate_restart)
|
|
38
38
|
self.server.restart()
|
|
39
|
-
self.router.info(
|
|
39
|
+
self.router.info(self.router.messages.restart_action_sent)
|
|
40
40
|
self.notifyWebhook('restartActionSent')
|
|
41
41
|
|
|
42
42
|
time.sleep(self.config.restart_wait_seconds)
|
|
@@ -49,12 +49,12 @@ class ActionPerformer:
|
|
|
49
49
|
timeout=self.config.restart_timeout,
|
|
50
50
|
interval=self.config.restart_online_interval,
|
|
51
51
|
):
|
|
52
|
-
self.router.info(
|
|
53
|
-
self.router.destination(
|
|
52
|
+
self.router.info(self.router.messages.server_back_online)
|
|
53
|
+
self.router.destination(self.router.messages.server_back_online_log)
|
|
54
54
|
self.notifyWebhook('serverBackOnline')
|
|
55
55
|
return True
|
|
56
56
|
|
|
57
|
-
self.router.error(
|
|
57
|
+
self.router.error(self.router.messages.server_failed_restart)
|
|
58
58
|
self.notifyWebhook('serverFailedRestart')
|
|
59
59
|
return False
|
|
60
60
|
|
|
@@ -74,8 +74,8 @@ class ActionPerformer:
|
|
|
74
74
|
target = target + timedelta(minutes=snap_step)
|
|
75
75
|
|
|
76
76
|
time_string = target.strftime('%I:%M %p')
|
|
77
|
-
self.router.info(
|
|
78
|
-
self.router.broadcast(
|
|
77
|
+
self.router.info(self.router.messages.scheduled, time=time_string)
|
|
78
|
+
self.router.broadcast(self.router.messages.broadcast_restart_at, time=time_string)
|
|
79
79
|
self.notifyWebhook('restartScheduled', time=time_string)
|
|
80
80
|
|
|
81
81
|
announced_minutes = set()
|
|
@@ -88,16 +88,16 @@ class ActionPerformer:
|
|
|
88
88
|
remaining_minutes = remaining_seconds // 60
|
|
89
89
|
if remaining_minutes in self.config.snap_minutes and remaining_minutes not in announced_minutes:
|
|
90
90
|
plural = '' if remaining_minutes == 1 else 's'
|
|
91
|
-
message =
|
|
92
|
-
self.router.broadcast(message)
|
|
93
|
-
self.router.origin(message)
|
|
91
|
+
message = self.router.messages.minute_template
|
|
92
|
+
self.router.broadcast(message, n=remaining_minutes, s=plural)
|
|
93
|
+
self.router.origin(message, n=remaining_minutes, s=plural)
|
|
94
94
|
announced_minutes.add(remaining_minutes)
|
|
95
95
|
|
|
96
96
|
if remaining_seconds <= 10 and remaining_seconds > 0 and remaining_seconds not in announced_seconds:
|
|
97
97
|
plural = '' if remaining_seconds == 1 else 's'
|
|
98
|
-
message =
|
|
99
|
-
self.router.broadcast(message)
|
|
100
|
-
self.router.origin(message)
|
|
98
|
+
message = self.router.messages.second_template
|
|
99
|
+
self.router.broadcast(message, n=remaining_seconds, s=plural)
|
|
100
|
+
self.router.origin(message, n=remaining_seconds, s=plural)
|
|
101
101
|
announced_seconds.add(remaining_seconds)
|
|
102
102
|
|
|
103
103
|
time.sleep(1)
|
|
@@ -2,6 +2,7 @@ import time
|
|
|
2
2
|
import logging
|
|
3
3
|
|
|
4
4
|
from calagoapi.utils.exceptions import CalagoAPIError
|
|
5
|
+
from hungercore import utils
|
|
5
6
|
from hungercore.webhook import WebhookClient
|
|
6
7
|
|
|
7
8
|
from .connection import setupServer
|
|
@@ -21,7 +22,7 @@ class ServerWatcher:
|
|
|
21
22
|
self.server = None
|
|
22
23
|
self.router = None
|
|
23
24
|
self.fetcher = None
|
|
24
|
-
self.evaluator = Evaluator(settings.evaluation)
|
|
25
|
+
self.evaluator = Evaluator(settings.evaluation, settings.messages)
|
|
25
26
|
self.action = None
|
|
26
27
|
self.webhook = None
|
|
27
28
|
if settings.config.bot_webhook_enabled:
|
|
@@ -75,6 +76,9 @@ class ServerWatcher:
|
|
|
75
76
|
|
|
76
77
|
def run(self):
|
|
77
78
|
try:
|
|
79
|
+
if settings.logging.enable_terminal_clearing:
|
|
80
|
+
utils.clear()
|
|
81
|
+
|
|
78
82
|
self.startup()
|
|
79
83
|
except CalagoAPIError as error:
|
|
80
84
|
logger.error('ServerWatcher startup failed: %s', error)
|
|
@@ -92,7 +96,7 @@ class ServerWatcher:
|
|
|
92
96
|
missing = [name for name in ('ram_gib', 'cpu_percent', 'uptime_seconds', 'tps', 'players')
|
|
93
97
|
if metrics[name] is None]
|
|
94
98
|
if missing:
|
|
95
|
-
self.router.error(
|
|
99
|
+
self.router.error(settings.messages.sampling_failure, metrics=', '.join(missing))
|
|
96
100
|
self.notifyWebhook('sampling_fail')
|
|
97
101
|
time.sleep(settings.watcher.watch_interval)
|
|
98
102
|
continue
|
|
@@ -112,7 +116,10 @@ class ServerWatcher:
|
|
|
112
116
|
self.notifyWebhook('unexpectedError', error=str(error))
|
|
113
117
|
raise
|
|
114
118
|
except KeyboardInterrupt:
|
|
115
|
-
|
|
119
|
+
if settings.logging.handle_keyboard_interrupt:
|
|
120
|
+
self.router.info(settings.messages.shutdown)
|
|
121
|
+
else:
|
|
122
|
+
raise
|
|
116
123
|
finally:
|
|
117
124
|
if self.server is not None:
|
|
118
125
|
self.server.closeBridge()
|
{serverwatcher-1.dev8 → serverwatcher-1.dev10}/src/serverwatcher/configclasses/evaluation.py
RENAMED
|
@@ -17,7 +17,6 @@ class EvaluatorConfig:
|
|
|
17
17
|
threshold_min_uptime: float = 'thresholds.min_uptime'
|
|
18
18
|
|
|
19
19
|
threshold_players: int = 'thresholds.players'
|
|
20
|
-
threshold_max_players: int = 'thresholds.max_players'
|
|
21
20
|
|
|
22
21
|
threshold_tps: float = 'thresholds.tps'
|
|
23
22
|
threshold_tps_1m: float = 'thresholds.tps_1m'
|
|
@@ -38,7 +37,6 @@ class EvaluatorConfig:
|
|
|
38
37
|
weight_uptime: int = 'weights.uptime'
|
|
39
38
|
|
|
40
39
|
weight_players: int = 'weights.players'
|
|
41
|
-
weight_max_players: int = 'weights.max_players'
|
|
42
40
|
|
|
43
41
|
weight_tps: int = 'weights.tps'
|
|
44
42
|
weight_tps_1m: int = 'weights.tps_1m'
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
from mapres import datamap
|
|
2
|
+
|
|
3
|
+
@datamap.braces.config(recursive=True)
|
|
4
|
+
class LoggingConfig:
|
|
5
|
+
__user_config_path__ = 'config/logging.yaml'
|
|
6
|
+
__default_config_path__ = 'defaultconfigs/logging.yaml'
|
|
7
|
+
|
|
8
|
+
logger_name: str = 'logger.name'
|
|
9
|
+
log_path: str = 'logger.log_path'
|
|
10
|
+
|
|
11
|
+
info_prefix: str = 'prefixes.info'
|
|
12
|
+
warn_prefix: str = 'prefixes.warn'
|
|
13
|
+
error_prefix: str = 'prefixes.error'
|
|
14
|
+
debug_prefix: str = 'prefixes.debug'
|
|
15
|
+
fatal_prefix: str = 'prefixes.fatal'
|
|
16
|
+
|
|
17
|
+
enable_terminal_clearing: bool = 'terminal.enable_clearing'
|
|
18
|
+
handle_keyboard_interrupt: bool = 'terminal.handle_keyboard_interrupt'
|
|
19
|
+
|
|
20
|
+
timezone: str = 'timezone'
|
|
@@ -6,38 +6,30 @@ class MessagesConfig:
|
|
|
6
6
|
__default_config_path__ = 'defaultconfigs/messages.yaml'
|
|
7
7
|
|
|
8
8
|
prefix: str = 'prefix'
|
|
9
|
-
bullet: str = 'bullet'
|
|
10
|
-
|
|
11
9
|
broadcast_restart_at: str = 'broadcast_restart_at'
|
|
12
|
-
|
|
13
10
|
minute_template: str = 'broadcast_templates.minutes'
|
|
14
11
|
second_template: str = 'broadcast_templates.seconds'
|
|
15
12
|
|
|
16
13
|
startup: str = 'logging.startup'
|
|
17
|
-
status_check: str = 'logging.status_check'
|
|
18
|
-
validation_fail: str = 'logging.validation_fail'
|
|
19
|
-
validation_ok: str = 'logging.validation_ok'
|
|
20
|
-
sampling_start: str = 'logging.sampling_start'
|
|
21
14
|
shutdown: str = 'logging.shutdown'
|
|
15
|
+
sampling_failure: str = 'logging.sampling_failure'
|
|
16
|
+
scheduled: str = 'logging.scheduled'
|
|
22
17
|
immediate_restart: str = 'logging.immediate_restart'
|
|
23
18
|
no_restart: str = 'logging.no_restart'
|
|
24
|
-
scheduled: str = 'logging.scheduled'
|
|
25
|
-
gap_low: str = 'logging.gap_low'
|
|
26
|
-
gap_high: str = 'logging.gap_high'
|
|
27
19
|
|
|
28
|
-
pro_restart_splash: str = 'reasons.pro_splash'
|
|
29
|
-
anti_restart_splash: str = 'reasons.anti_splash'
|
|
30
|
-
|
|
31
|
-
reason_restart_soon: str = 'reasons.restart_soon'
|
|
32
20
|
reason_ram: str = 'reasons.ram'
|
|
33
21
|
reason_cpu: str = 'reasons.cpu'
|
|
34
22
|
reason_uptime: str = 'reasons.uptime'
|
|
35
|
-
reason_tps: str = 'reasons.tps'
|
|
36
|
-
reason_low_uptime: str = 'reasons.low_uptime'
|
|
37
23
|
reason_players: str = 'reasons.players'
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
24
|
+
reason_tps: str = 'reasons.tps'
|
|
25
|
+
reason_tps_1m: str = 'reasons.tps_1m'
|
|
26
|
+
reason_tps_5m: str = 'reasons.tps_5m'
|
|
27
|
+
reason_tps_15m: str = 'reasons.tps_15m'
|
|
28
|
+
reason_mspt: str = 'reasons.mspt'
|
|
29
|
+
reason_loaded_chunks: str = 'reasons.loaded_chunks'
|
|
30
|
+
reason_loaded_entities: str = 'reasons.loaded_entities'
|
|
31
|
+
reason_gc_pause_ms: str = 'reasons.gc_pause_ms'
|
|
32
|
+
reason_thread_peak: str = 'reasons.thread_peak'
|
|
41
33
|
|
|
42
34
|
restart_action_sent: str = 'restarts.restart_action_sent'
|
|
43
35
|
server_back_online: str = 'restarts.back_online'
|
|
@@ -17,14 +17,3 @@ hungernetbot:
|
|
|
17
17
|
enabled: False
|
|
18
18
|
url: 'https://bot.example.com/webhook'
|
|
19
19
|
token: 'CHANGE_ME'
|
|
20
|
-
|
|
21
|
-
logger:
|
|
22
|
-
name: 'ServerWatcher'
|
|
23
|
-
log_path: '/home/container/logs/'
|
|
24
|
-
|
|
25
|
-
terminal:
|
|
26
|
-
enable_clearing: True
|
|
27
|
-
handle_keyboard_interrupt: True
|
|
28
|
-
|
|
29
|
-
debug: False
|
|
30
|
-
timezone: 'America/Chicago'
|
{serverwatcher-1.dev8 → serverwatcher-1.dev10}/src/serverwatcher/defaultconfigs/evaluation.yaml
RENAMED
|
@@ -9,8 +9,7 @@ thresholds:
|
|
|
9
9
|
uptime: 12 # minutes
|
|
10
10
|
min_uptime: 30 # do not restart if uptime < 30 minutes
|
|
11
11
|
|
|
12
|
-
players: 0
|
|
13
|
-
max_players: 0 # usually unused
|
|
12
|
+
players: 0
|
|
14
13
|
|
|
15
14
|
tps: 19.5
|
|
16
15
|
tps_1m: 19.5
|
|
@@ -31,7 +30,6 @@ weights:
|
|
|
31
30
|
uptime: 1
|
|
32
31
|
|
|
33
32
|
players: 1
|
|
34
|
-
max_players: 0
|
|
35
33
|
|
|
36
34
|
tps: 3
|
|
37
35
|
tps_1m: 1
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
logger:
|
|
2
|
+
name: 'ServerWatcher'
|
|
3
|
+
log_path: '/home/container/logs/'
|
|
4
|
+
|
|
5
|
+
prefixes:
|
|
6
|
+
info: '<white>[%hh%:%mm%:%ss%] [INFO]: '
|
|
7
|
+
warn: '<yellow>[%hh%:%mm%:%ss%] [WARN]: '
|
|
8
|
+
error: '<red>[%hh%:%mm%:%ss%] [ERROR]: '
|
|
9
|
+
debug: '<aqua>[%hh%:%mm%:%ss%] [DEBUG]: '
|
|
10
|
+
fatal: '<dark_red>[%hh%:%mm%:%ss%] [FATAL]: '
|
|
11
|
+
|
|
12
|
+
terminal:
|
|
13
|
+
enable_clearing: True
|
|
14
|
+
handle_keyboard_interrupt: True
|
|
15
|
+
|
|
16
|
+
timezone: 'America/Chicago'
|
{serverwatcher-1.dev8 → serverwatcher-1.dev10}/src/serverwatcher/defaultconfigs/messages.yaml
RENAMED
|
@@ -39,7 +39,6 @@
|
|
|
39
39
|
# %weekday%
|
|
40
40
|
|
|
41
41
|
prefix: '<aqua>[Server Watcher]'
|
|
42
|
-
bullet: '-'
|
|
43
42
|
|
|
44
43
|
broadcast_restart_at: '{{prefix}} The server will restart at {{time}} CDT.'
|
|
45
44
|
|
|
@@ -47,36 +46,28 @@ broadcast_templates:
|
|
|
47
46
|
minutes: '{{prefix}} Restart in {{n}} minute{{s}}!'
|
|
48
47
|
seconds: '{{prefix}} <red>Restarting in {{n}} second{{s}}!'
|
|
49
48
|
|
|
50
|
-
broadcast_minutes: {}
|
|
51
|
-
broadcast_seconds: {}
|
|
52
|
-
|
|
53
49
|
logging:
|
|
54
50
|
startup: 'ServerWatcher is running!'
|
|
55
|
-
status_check: 'Checking server status...'
|
|
56
|
-
validation_fail: 'Validation FAILED.'
|
|
57
|
-
validation_ok: 'All validation checks succeeded.'
|
|
58
|
-
sampling_start: 'Starting sampling process. This should take about {{duration}} seconds...'
|
|
59
51
|
shutdown: 'Shutting down ServerWatcher.'
|
|
52
|
+
sampling_failure: 'Sampling failed - missing metrics: {{metrics}}'
|
|
53
|
+
scheduled: 'Scheduling restart for {{time}}.'
|
|
60
54
|
immediate_restart: 'Restarting immediately.'
|
|
61
55
|
no_restart: 'The server does not need to restart.'
|
|
62
|
-
scheduled: 'Restart needed, but anti-restart factors outweigh it.'
|
|
63
|
-
gap_low: 'Gap {{gap}}. Scheduling restart in 2 hours.'
|
|
64
|
-
gap_high: 'Gap {{gap}}. Scheduling restart in 1 hour.'
|
|
65
56
|
|
|
66
57
|
reasons:
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
58
|
+
ram: 'ram: {{value}} exceeded its threshold of {{threshold}} GiB'
|
|
59
|
+
cpu: 'cpu: {{value}} exceeded its threshold of {{threshold}}%'
|
|
60
|
+
uptime: 'uptime: {{value}} fell below its threshold of {{threshold}} minutes'
|
|
61
|
+
players: 'players: {{value}} exceeded its threshold of {{threshold}}'
|
|
62
|
+
tps: 'tps: {{value}} fell below its threshold of {{threshold}}'
|
|
63
|
+
tps_1m: 'tps_1m: {{value}} fell below its threshold of {{threshold}}'
|
|
64
|
+
tps_5m: 'tps_5m: {{value}} fell below its threshold of {{threshold}}'
|
|
65
|
+
tps_15m: 'tps_15m: {{value}} fell below its threshold of {{threshold}}'
|
|
66
|
+
mspt: 'mspt: {{value}} exceeded its threshold of {{threshold}} ms'
|
|
67
|
+
loaded_chunks: 'loaded_chunks: {{value}} exceeded its threshold of {{threshold}}'
|
|
68
|
+
loaded_entities: 'loaded_entities: {{value}} exceeded its threshold of {{threshold}}'
|
|
69
|
+
gc_pause_ms: 'gc_pause_ms: {{value}} exceeded its threshold of {{threshold}} ms'
|
|
70
|
+
thread_peak: 'thread_peak: {{value}} exceeded its threshold of {{threshold}}'
|
|
80
71
|
|
|
81
72
|
restarts:
|
|
82
73
|
restart_action_sent: 'Restart action sent. Waiting...'
|
|
@@ -1,6 +1,12 @@
|
|
|
1
|
+
from mapres import MapResolver
|
|
2
|
+
|
|
3
|
+
|
|
1
4
|
class Evaluator:
|
|
2
|
-
def __init__(self, config):
|
|
5
|
+
def __init__(self, config, messages):
|
|
3
6
|
self.config = config
|
|
7
|
+
self.messages = messages
|
|
8
|
+
self.resolver = MapResolver()
|
|
9
|
+
self.resolver.layers.add_layer(messages)
|
|
4
10
|
|
|
5
11
|
def evaluate(self, metrics):
|
|
6
12
|
score = 0
|
|
@@ -15,7 +21,11 @@ class Evaluator:
|
|
|
15
21
|
bad = value > threshold if compare == '>' else value < threshold
|
|
16
22
|
if bad:
|
|
17
23
|
score += weight
|
|
18
|
-
|
|
24
|
+
template = getattr(self.messages, f'reason_{name}')
|
|
25
|
+
reasons.append(self.resolver.res(
|
|
26
|
+
template,
|
|
27
|
+
extra_maps={'value': value, 'threshold': threshold},
|
|
28
|
+
))
|
|
19
29
|
|
|
20
30
|
check('ram', metrics['ram_gib'], self.config.threshold_ram, self.config.weight_ram, '>')
|
|
21
31
|
check('cpu', metrics['cpu_percent'], self.config.threshold_cpu, self.config.weight_cpu, '>')
|
|
@@ -47,10 +47,8 @@ class MetricFetcher:
|
|
|
47
47
|
player_stats = self._get(self.server.bridge.getPlayerStats)
|
|
48
48
|
if player_stats:
|
|
49
49
|
players = player_stats.get('count')
|
|
50
|
-
max_players = player_stats.get('max')
|
|
51
50
|
else:
|
|
52
51
|
players = None
|
|
53
|
-
max_players = None
|
|
54
52
|
|
|
55
53
|
tps_stats = self._get(self.server.bridge.getTPSStats)
|
|
56
54
|
if tps_stats:
|
|
@@ -75,7 +73,6 @@ class MetricFetcher:
|
|
|
75
73
|
'uptime_seconds': uptime_seconds,
|
|
76
74
|
|
|
77
75
|
'players': players,
|
|
78
|
-
'max_players': max_players,
|
|
79
76
|
|
|
80
77
|
'tps': tps,
|
|
81
78
|
'tps_1m': tps_1m,
|
|
@@ -33,6 +33,9 @@ class Router:
|
|
|
33
33
|
name=logger_name,
|
|
34
34
|
Servers=servers,
|
|
35
35
|
log_path=self.logging.log_path,
|
|
36
|
+
info_prefix=self.logging.info_prefix,
|
|
37
|
+
warn_prefix=self.logging.warn_prefix,
|
|
38
|
+
error_prefix=self.logging.error_prefix,
|
|
36
39
|
common_maps=common_maps,
|
|
37
40
|
origin_maps=[maps.ascii_colors],
|
|
38
41
|
destination_maps=[maps.ascii_colors],
|
|
@@ -45,13 +48,13 @@ class Router:
|
|
|
45
48
|
|
|
46
49
|
self.router.registerLevel(
|
|
47
50
|
name='debug',
|
|
48
|
-
prefix=
|
|
51
|
+
prefix=self.logging.debug_prefix,
|
|
49
52
|
file_method='debug',
|
|
50
53
|
routes=['origin'],
|
|
51
54
|
)
|
|
52
55
|
self.router.registerLevel(
|
|
53
56
|
name='fatal',
|
|
54
|
-
prefix=
|
|
57
|
+
prefix=self.logging.fatal_prefix,
|
|
55
58
|
file_method='fatal',
|
|
56
59
|
routes=['origin'],
|
|
57
60
|
)
|
|
@@ -16,7 +16,7 @@ class SettingsManager:
|
|
|
16
16
|
self.config_dir.mkdir(parents=True, exist_ok=True)
|
|
17
17
|
self.config = loadConfig(GlobalConfig, runtime_path=str(self.config_dir / 'config.yaml'))
|
|
18
18
|
self.evaluation = loadConfig(EvaluatorConfig, runtime_path=str(self.config_dir / 'evaluation.yaml'))
|
|
19
|
-
self.logging = loadConfig(LoggingConfig, runtime_path=str(self.config_dir / '
|
|
19
|
+
self.logging = loadConfig(LoggingConfig, runtime_path=str(self.config_dir / 'logging.yaml'))
|
|
20
20
|
self.messages = loadConfig(MessagesConfig, runtime_path=str(self.config_dir / 'messages.yaml'))
|
|
21
21
|
self.watcher = loadConfig(WatcherConfig, runtime_path=str(self.config_dir / 'watcher.yaml'))
|
|
22
22
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: serverwatcher
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.dev10
|
|
4
4
|
Summary: A HungerCore-powered Minecraft server automation engine.
|
|
5
5
|
Author: iFamished
|
|
6
6
|
License: GPL-3.0
|
|
@@ -63,7 +63,7 @@ The egg defaults to the `main` branch and enables startup auto-updates. Set `AUT
|
|
|
63
63
|
|
|
64
64
|
`HUNGERLIB_DEV`, `MAPRES_DEV`, and `C2E_DEV` each upgrade their package to the latest prerelease with `uv` on every startup; C2E is optional and is not required by ServerWatcher itself. Choose the ServerWatcher source branch with `GIT_BRANCH`.
|
|
65
65
|
|
|
66
|
-
The YAML files in `src/serverwatcher/defaultconfigs/` are the
|
|
66
|
+
The YAML files in `src/serverwatcher/defaultconfigs/` are the packaged defaults. MapRes copies each one into `/home/container/config/` on first startup and fills missing keys with defaults without replacing overrides. The runtime files are not committed as duplicate defaults: `config.yaml` contains server/API/webhook settings, `logging.yaml` contains logging and terminal settings, and `evaluation.yaml`, `messages.yaml`, and `watcher.yaml` contain their matching settings. `SERVERWATCHER_CONFIG_DIR` can override this path for non-container installs.
|
|
67
67
|
|
|
68
68
|
## HungerNet Bot Webhook
|
|
69
69
|
Set `hungernetbot.enabled` to `True`, `hungernetbot.url` to the Bot's `/webhook` endpoint, and `hungernetbot.token` to the same secret configured as `BRIDGE_WEBHOOK_TOKEN` in HungerNet Bot. For example:
|
|
@@ -41,5 +41,6 @@ src/serverwatcher/configclasses/messages.py
|
|
|
41
41
|
src/serverwatcher/configclasses/watcher.py
|
|
42
42
|
src/serverwatcher/defaultconfigs/config.yaml
|
|
43
43
|
src/serverwatcher/defaultconfigs/evaluation.yaml
|
|
44
|
+
src/serverwatcher/defaultconfigs/logging.yaml
|
|
44
45
|
src/serverwatcher/defaultconfigs/messages.yaml
|
|
45
46
|
src/serverwatcher/defaultconfigs/watcher.yaml
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
from mapres import datamap
|
|
2
|
-
|
|
3
|
-
@datamap.braces.config(recursive=True)
|
|
4
|
-
class LoggingConfig:
|
|
5
|
-
__user_config_path__ = 'config/config.yaml'
|
|
6
|
-
__default_config_path__ = 'defaultconfigs/config.yaml'
|
|
7
|
-
|
|
8
|
-
logger_name: str = 'logger.name'
|
|
9
|
-
log_path: str = 'logger.log_path'
|
|
10
|
-
|
|
11
|
-
enable_terminal_clearing: bool = 'terminal.enable_clearing'
|
|
12
|
-
handle_keyboard_interrupt: bool = 'terminal.handle_keyboard_interrupt'
|
|
13
|
-
|
|
14
|
-
debug: bool = 'debug'
|
|
15
|
-
timezone: str = 'timezone'
|
|
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
|
|
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
|
{serverwatcher-1.dev8 → serverwatcher-1.dev10}/src/serverwatcher/defaultconfigs/watcher.yaml
RENAMED
|
File without changes
|
{serverwatcher-1.dev8 → serverwatcher-1.dev10}/src/serverwatcher.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|