serverwatcher 1.dev5__py3-none-any.whl → 1.dev7__py3-none-any.whl

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/app.py CHANGED
@@ -1,6 +1,7 @@
1
1
  import time
2
2
  import logging
3
3
 
4
+ from calagoapi.utils.exceptions import CalagoAPIError
4
5
  from hungercore.webhook import WebhookClient
5
6
 
6
7
  from .connection import setupServer
@@ -73,7 +74,12 @@ class ServerWatcher:
73
74
  return 'schedule_restart', settings.watcher.high_gap_minutes
74
75
 
75
76
  def run(self):
76
- self.startup()
77
+ try:
78
+ self.startup()
79
+ except CalagoAPIError as error:
80
+ logger.error('ServerWatcher startup failed: %s', error)
81
+ logger.error('Update the required values in %s/config.yaml and restart.', settings.config_dir)
82
+ raise SystemExit(1) from None
77
83
 
78
84
  try:
79
85
  while True:
@@ -8,7 +8,32 @@ from .settings import settings
8
8
  enable('minecraft')
9
9
 
10
10
 
11
+ def validateConfiguration():
12
+ required = {
13
+ 'server.domain': settings.config.server_domain,
14
+ 'calagoapi.url': settings.config.panel_url,
15
+ 'calagoapi.api_key': settings.config.panel_api_key,
16
+ 'calagoapi.server_id': settings.config.server_id,
17
+ 'hungerbridge.url': settings.config.bridge_url,
18
+ 'hungerbridge.token_id': settings.config.bridge_token_id,
19
+ 'hungerbridge.token_secret': settings.config.bridge_token_secret,
20
+ }
21
+ unset = []
22
+ for key, value in required.items():
23
+ normalized = str(value).strip().lower() if value is not None else ''
24
+ if not normalized or normalized == 'change_me' or 'example.com' in normalized:
25
+ unset.append(key)
26
+
27
+ if unset:
28
+ keys = ', '.join(unset)
29
+ config_path = settings.config_dir / 'config.yaml'
30
+ raise CalagoAPIError(
31
+ f'Configuration is incomplete. Set {keys} in {config_path} before starting ServerWatcher.'
32
+ )
33
+
34
+
11
35
  def setupServer():
36
+ validateConfiguration()
12
37
  panel = Panel(
13
38
  url=settings.config.panel_url,
14
39
  api_key=settings.config.panel_api_key,
serverwatcher/settings.py CHANGED
@@ -1,3 +1,6 @@
1
+ import os
2
+ from pathlib import Path
3
+
1
4
  from mapres import loadConfig
2
5
 
3
6
  from serverwatcher.configclasses.config import GlobalConfig
@@ -9,10 +12,12 @@ from serverwatcher.configclasses.watcher import WatcherConfig
9
12
 
10
13
  class SettingsManager:
11
14
  def __init__(self):
12
- self.config = loadConfig(GlobalConfig)
13
- self.evaluation = loadConfig(EvaluatorConfig)
14
- self.logging = loadConfig(LoggingConfig)
15
- self.messages = loadConfig(MessagesConfig)
16
- self.watcher = loadConfig(WatcherConfig)
15
+ self.config_dir = Path(os.environ.get('SERVERWATCHER_CONFIG_DIR', '/home/container/config'))
16
+ self.config_dir.mkdir(parents=True, exist_ok=True)
17
+ self.config = loadConfig(GlobalConfig, runtime_path=str(self.config_dir / 'config.yaml'))
18
+ self.evaluation = loadConfig(EvaluatorConfig, runtime_path=str(self.config_dir / 'evaluation.yaml'))
19
+ self.logging = loadConfig(LoggingConfig, runtime_path=str(self.config_dir / 'config.yaml'))
20
+ self.messages = loadConfig(MessagesConfig, runtime_path=str(self.config_dir / 'messages.yaml'))
21
+ self.watcher = loadConfig(WatcherConfig, runtime_path=str(self.config_dir / 'watcher.yaml'))
17
22
 
18
23
  settings = SettingsManager()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: serverwatcher
3
- Version: 1.dev5
3
+ Version: 1.dev7
4
4
  Summary: A HungerCore-powered Minecraft server automation engine.
5
5
  Author: iFamished
6
6
  License: GPL-3.0
@@ -55,13 +55,15 @@ A highly configurable Minecraft server monitoring and restart engine for HungerB
55
55
  ## Installation
56
56
  - Import the [ServerWatcher Pterodactyl egg](https://github.com/HungerNet/ServerWatcher/blob/main/eggs/egg-serverwatcher.json) into your panel and create a server with Python 3.14.
57
57
  - Run the installer. It checks out the configured Git branch and installs `uv`; Python dependencies are synced on startup.
58
- - Start the server once to generate the runtime YAML files in `config/`. Set the required panel/server credentials in `config/config.yaml`, then restart.
58
+ - Start the server once to generate the runtime YAML files in `/home/container/config/`. Set the required panel/server credentials in `/home/container/config/config.yaml`, then restart.
59
59
  - Missing runtime files are copied from packaged defaults without overwriting existing files. The example panel and API credentials are placeholders, so valid credentials are required before the watcher can connect.
60
60
  - Subsequent starts update the checkout when `AUTO_UPDATE` is enabled, sync the Python environment, and run ServerWatcher.
61
61
 
62
62
  The egg defaults to the `main` branch and enables startup auto-updates. Set `AUTO_UPDATE` to `0` to keep the installed checkout fixed, or change `GIT_BRANCH` to use another branch.
63
63
 
64
- The YAML files in `src/serverwatcher/defaultconfigs/` are the canonical packaged defaults. MapRes copies each one into the ignored runtime `config/` directory on first startup; edit the runtime files, which are never committed as a second source of defaults. `config/config.yaml` contains server/API and logging settings; `evaluation.yaml`, `messages.yaml`, and `watcher.yaml` contain their corresponding settings.
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
+
66
+ The YAML files in `src/serverwatcher/defaultconfigs/` are the canonical packaged defaults. MapRes copies each one into `/home/container/config/` on first startup; edit these runtime files, which are not committed as a second source of defaults. `config.yaml` contains server/API and logging settings; `evaluation.yaml`, `messages.yaml`, and `watcher.yaml` contain their corresponding settings. `SERVERWATCHER_CONFIG_DIR` can override this path for non-container installs.
65
67
 
66
68
  ## HungerNet Bot Webhook
67
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:
@@ -18,12 +18,12 @@ old/configclasses/watcher.py,sha256=8BakRRuFjUzPu1Ms0ZW0sDRHIKNVkEs8Pp7LpguGTpM,
18
18
  serverwatcher/__init__.py,sha256=wWcS5N5e-1_MN7NCN93PbMok9G0CdvRn_-dfu4YsGPk,75
19
19
  serverwatcher/__main__.py,sha256=0GGlvDUxdGolvIqo82N8a7QeJqTNQX-7M_WeylmPUIw,62
20
20
  serverwatcher/actionperformer.py,sha256=9_Fg-WLBhQaYPmax6v_tIWe1S1D5Zudv5We2yLlNdOk,4127
21
- serverwatcher/app.py,sha256=UVPFjbtBlGIogIvmcw07aY6dvJVsnhCeDDb-tbc9lww,3970
22
- serverwatcher/connection.py,sha256=Zf-_1pzd0Clwp2xpuWhl7hd3PRgX4rdjUNvUlZP9x80,1095
21
+ serverwatcher/app.py,sha256=wwR62SVog0vmN8vgTUo1goygZS6qPjZgXDaHRFUJawo,4298
22
+ serverwatcher/connection.py,sha256=PUmB1yZuqbXm6J_UDo7GmqQb3107ynURA3Ct-m658d0,2096
23
23
  serverwatcher/evaluator.py,sha256=Y5YvWpqv6yJmIOlkCggT4e226WtXwhnwyXABASENEmI,2618
24
24
  serverwatcher/metricfetcher.py,sha256=wJMw96lWEWm8agKo0sYHSmCYii46mIDImPOYW99QRos,2910
25
25
  serverwatcher/router.py,sha256=B8EF7RELG7JflcUWPdUmZB4Rp4pDCkZdsmr-ZHbARj8,2085
26
- serverwatcher/settings.py,sha256=afhiXqsMnNOMk354dJXfqPeM2IKE96cDSr6UFdSjh0M,675
26
+ serverwatcher/settings.py,sha256=EtRz_e4Hi2F5NZPMeufbfjCCRWV4A0I_Jyf9QmNOhkI,1133
27
27
  serverwatcher/configclasses/__init__.py,sha256=PLLzlldBbriJlzPvzCQhne9WVoKOu0qCv4QzMqpg0hE,312
28
28
  serverwatcher/configclasses/config.py,sha256=Q0ZpVe9wsLOCvkfJ2C5QEssRYC7_Wa6LyGxlcUNVs9Y,740
29
29
  serverwatcher/configclasses/evaluation.py,sha256=9lZbu9OCO5vR_LODjMxIH4w0lLKcOuZitN_ObDAfMeM,1854
@@ -34,9 +34,9 @@ serverwatcher/defaultconfigs/config.yaml,sha256=GGTM5rnw8jpWT9iasyT_m4vSdfz2tw4h
34
34
  serverwatcher/defaultconfigs/evaluation.yaml,sha256=pmV3b8Ln7ZGUCtaECdypcjVr0RefYy7yWf3d9eBFYZw,733
35
35
  serverwatcher/defaultconfigs/messages.yaml,sha256=jSVEl-RYqPHhe5U5KLl8zfJtUBymvyE74hmzH0RFC_Y,3177
36
36
  serverwatcher/defaultconfigs/watcher.yaml,sha256=iev4whdLrGBWE9zcmuMrUNnZc89iaxujKjUWqdWKGv0,189
37
- serverwatcher-1.dev5.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
38
- serverwatcher-1.dev5.dist-info/METADATA,sha256=2Q_P2pYKRb_P4f5tQYtW0hFtaL2_CXVlpmvIYaPwgEg,4227
39
- serverwatcher-1.dev5.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
40
- serverwatcher-1.dev5.dist-info/entry_points.txt,sha256=5d464Lg4-6S6_1bS71BnHAXds6Yyw6vMrrkUMlB7LDQ,57
41
- serverwatcher-1.dev5.dist-info/top_level.txt,sha256=BSOmfMtsjx7XwYL55cWMZb7rp48ow5Jry9qmMncah8U,18
42
- serverwatcher-1.dev5.dist-info/RECORD,,
37
+ serverwatcher-1.dev7.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
38
+ serverwatcher-1.dev7.dist-info/METADATA,sha256=g0NSUetC3zwYDxELYUSV0Ab-ui1iFZQsPtFjYyu7V6w,4561
39
+ serverwatcher-1.dev7.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
40
+ serverwatcher-1.dev7.dist-info/entry_points.txt,sha256=5d464Lg4-6S6_1bS71BnHAXds6Yyw6vMrrkUMlB7LDQ,57
41
+ serverwatcher-1.dev7.dist-info/top_level.txt,sha256=BSOmfMtsjx7XwYL55cWMZb7rp48ow5Jry9qmMncah8U,18
42
+ serverwatcher-1.dev7.dist-info/RECORD,,