serverwatcher 1__tar.gz → 1.dev4__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.dev4/PKG-INFO +76 -0
- serverwatcher-1.dev4/README.md +45 -0
- {serverwatcher-1 → serverwatcher-1.dev4}/pyproject.toml +23 -13
- serverwatcher-1.dev4/src/old/__init__.py +17 -0
- serverwatcher-1.dev4/src/old/__main__.py +10 -0
- serverwatcher-1.dev4/src/old/actionperformer.py +147 -0
- serverwatcher-1.dev4/src/old/configclasses/__init__.py +13 -0
- serverwatcher-1.dev4/src/old/configclasses/config.py +52 -0
- serverwatcher-1.dev4/src/old/configclasses/discord.py +23 -0
- serverwatcher-1.dev4/src/old/configclasses/environment.py +38 -0
- serverwatcher-1.dev4/src/old/configclasses/evaluation.py +110 -0
- serverwatcher-1.dev4/src/old/configclasses/messages.py +89 -0
- serverwatcher-1.dev4/src/old/configclasses/watcher.py +42 -0
- serverwatcher-1.dev4/src/old/configmanager.py +146 -0
- serverwatcher-1.dev4/src/old/evaluator.py +60 -0
- serverwatcher-1.dev4/src/old/exceptions.py +4 -0
- serverwatcher-1.dev4/src/old/metricfetcher.py +92 -0
- serverwatcher-1.dev4/src/old/router.py +102 -0
- serverwatcher-1.dev4/src/old/targetserver.py +154 -0
- serverwatcher-1.dev4/src/old/watcher.py +152 -0
- serverwatcher-1.dev4/src/serverwatcher/__init__.py +4 -0
- serverwatcher-1.dev4/src/serverwatcher/__main__.py +5 -0
- serverwatcher-1.dev4/src/serverwatcher/actionperformer.py +105 -0
- serverwatcher-1.dev4/src/serverwatcher/app.py +122 -0
- serverwatcher-1.dev4/src/serverwatcher/configclasses/__init__.py +13 -0
- serverwatcher-1.dev4/src/serverwatcher/configclasses/config.py +22 -0
- serverwatcher-1.dev4/src/serverwatcher/configclasses/evaluation.py +54 -0
- serverwatcher-1.dev4/src/serverwatcher/configclasses/logging.py +15 -0
- serverwatcher-1.dev4/src/serverwatcher/configclasses/messages.py +45 -0
- serverwatcher-1.dev4/src/serverwatcher/configclasses/watcher.py +18 -0
- serverwatcher-1.dev4/src/serverwatcher/connection.py +37 -0
- serverwatcher-1.dev4/src/serverwatcher/defaultconfigs/config.yaml +30 -0
- serverwatcher-1.dev4/src/serverwatcher/defaultconfigs/evaluation.yaml +47 -0
- serverwatcher-1.dev4/src/serverwatcher/defaultconfigs/messages.yaml +85 -0
- serverwatcher-1.dev4/src/serverwatcher/defaultconfigs/watcher.yaml +12 -0
- serverwatcher-1.dev4/src/serverwatcher/evaluator.py +61 -0
- serverwatcher-1.dev4/src/serverwatcher/metricfetcher.py +91 -0
- serverwatcher-1.dev4/src/serverwatcher/router.py +66 -0
- serverwatcher-1.dev4/src/serverwatcher/settings.py +21 -0
- serverwatcher-1.dev4/src/serverwatcher.egg-info/PKG-INFO +76 -0
- serverwatcher-1.dev4/src/serverwatcher.egg-info/SOURCES.txt +45 -0
- serverwatcher-1.dev4/src/serverwatcher.egg-info/entry_points.txt +2 -0
- serverwatcher-1.dev4/src/serverwatcher.egg-info/requires.txt +5 -0
- {serverwatcher-1 → serverwatcher-1.dev4}/src/serverwatcher.egg-info/top_level.txt +1 -0
- serverwatcher-1/PKG-INFO +0 -41
- serverwatcher-1/README.md +0 -13
- serverwatcher-1/src/serverwatcher/__init__.py +0 -33
- serverwatcher-1/src/serverwatcher/config.py +0 -33
- serverwatcher-1/src/serverwatcher/messages.py +0 -42
- serverwatcher-1/src/serverwatcher/watcher.py +0 -162
- serverwatcher-1/src/serverwatcher.egg-info/PKG-INFO +0 -41
- serverwatcher-1/src/serverwatcher.egg-info/SOURCES.txt +0 -12
- serverwatcher-1/src/serverwatcher.egg-info/requires.txt +0 -2
- {serverwatcher-1 → serverwatcher-1.dev4}/LICENSE +0 -0
- {serverwatcher-1 → serverwatcher-1.dev4}/setup.cfg +0 -0
- {serverwatcher-1 → serverwatcher-1.dev4}/src/serverwatcher.egg-info/dependency_links.txt +0 -0
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: serverwatcher
|
|
3
|
+
Version: 1.dev4
|
|
4
|
+
Summary: A HungerCore-powered Minecraft server automation engine.
|
|
5
|
+
Author: iFamished
|
|
6
|
+
License: GPL-3.0
|
|
7
|
+
Project-URL: Homepage, https://github.com/iFamished/ServerWatcher
|
|
8
|
+
Project-URL: Documentation, https://github.com/iFamished/ServerWatcher
|
|
9
|
+
Project-URL: Source, https://github.com/iFamished/ServerWatcher
|
|
10
|
+
Project-URL: Issues, https://github.com/iFamished/ServerWatcher/issues
|
|
11
|
+
Keywords: pterodactyl,minecraft,automation,server-management,hungercore,hungernet
|
|
12
|
+
Classifier: Programming Language :: Python :: 3
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
16
|
+
Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3)
|
|
17
|
+
Classifier: Operating System :: OS Independent
|
|
18
|
+
Classifier: Development Status :: 4 - Beta
|
|
19
|
+
Classifier: Intended Audience :: Developers
|
|
20
|
+
Classifier: Topic :: Software Development :: Libraries
|
|
21
|
+
Classifier: Topic :: System :: Systems Administration
|
|
22
|
+
Requires-Python: >=3.14
|
|
23
|
+
Description-Content-Type: text/markdown
|
|
24
|
+
License-File: LICENSE
|
|
25
|
+
Requires-Dist: calagoapi
|
|
26
|
+
Requires-Dist: calagoapi-minecraft
|
|
27
|
+
Requires-Dist: hungerbridge
|
|
28
|
+
Requires-Dist: hungercore
|
|
29
|
+
Requires-Dist: mapres
|
|
30
|
+
Dynamic: license-file
|
|
31
|
+
|
|
32
|
+
# ServerWatcher
|
|
33
|
+
A highly configurable Minecraft server monitoring and restart engine for HungerBridge / Pterodactyl-based Minecraft servers.
|
|
34
|
+
|
|
35
|
+
## System requirements
|
|
36
|
+
| | **Minimum** | **Recommended** |
|
|
37
|
+
| ----------- | ----------- | --------------- |
|
|
38
|
+
| **RAM** | 128 MB | 256 MB |
|
|
39
|
+
| **Storage** | 256 MB | 1 GB |
|
|
40
|
+
|
|
41
|
+
## Prerequisites
|
|
42
|
+
**Pterodactyl Panel / API credentials**
|
|
43
|
+
- You must have the server on a Pterodactyl Panel
|
|
44
|
+
- You need a valid client API token
|
|
45
|
+
**HungerBridge**
|
|
46
|
+
- Install [HungerBridge from Modrinth](https://modrinth.com/project/hungerbridge) on the Minecraft server you wish to monitor
|
|
47
|
+
- HungerBridge supports `Fabric`, `Quilt`, `Paper`, `Purpur`, and `Folia`
|
|
48
|
+
**A dedicated Python environment**
|
|
49
|
+
- ServerWatcher requires a Python 3.14+ environment to run
|
|
50
|
+
*HungerNet Bot*
|
|
51
|
+
- Optional. Configure its webhook endpoint and shared token in `config/config.yaml`.
|
|
52
|
+
*Logging directory*
|
|
53
|
+
- Optional. Only necessary if you want to use file logging.
|
|
54
|
+
|
|
55
|
+
## Installation
|
|
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
|
+
- 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 create the empty `config/` directory. Add the required panel/server credentials as local overrides in `config/config.yaml`, then restart.
|
|
59
|
+
- On startup, missing override files silently use their packaged defaults. The example panel and API credentials are placeholders, so valid credentials are required before the watcher can connect.
|
|
60
|
+
- Subsequent starts update the checkout when `AUTO_UPDATE` is enabled, sync the Python environment, and run ServerWatcher.
|
|
61
|
+
|
|
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
|
+
|
|
64
|
+
Defaults are loaded directly from the packaged YAML files in `src/serverwatcher/defaultconfigs/`; ServerWatcher does not copy them into the project directory. To override settings, create a matching YAML file under `config/` with only the values you want to change. MapRes merges those overrides over packaged defaults. `config/config.yaml` overrides server/API and logging settings; `evaluation.yaml`, `messages.yaml`, and `watcher.yaml` override their corresponding settings.
|
|
65
|
+
|
|
66
|
+
## HungerNet Bot Webhook
|
|
67
|
+
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:
|
|
68
|
+
|
|
69
|
+
```yaml
|
|
70
|
+
hungernetbot:
|
|
71
|
+
enabled: True
|
|
72
|
+
url: 'https://bot.example.com/webhook'
|
|
73
|
+
token: 'replace-with-the-shared-webhook-token'
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
The webhook reports restart scheduling and outcomes, sampling failures, and startup validation or unexpected errors. Leave it disabled if no HungerNet Bot receiver is configured.
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# ServerWatcher
|
|
2
|
+
A highly configurable Minecraft server monitoring and restart engine for HungerBridge / Pterodactyl-based Minecraft servers.
|
|
3
|
+
|
|
4
|
+
## System requirements
|
|
5
|
+
| | **Minimum** | **Recommended** |
|
|
6
|
+
| ----------- | ----------- | --------------- |
|
|
7
|
+
| **RAM** | 128 MB | 256 MB |
|
|
8
|
+
| **Storage** | 256 MB | 1 GB |
|
|
9
|
+
|
|
10
|
+
## Prerequisites
|
|
11
|
+
**Pterodactyl Panel / API credentials**
|
|
12
|
+
- You must have the server on a Pterodactyl Panel
|
|
13
|
+
- You need a valid client API token
|
|
14
|
+
**HungerBridge**
|
|
15
|
+
- Install [HungerBridge from Modrinth](https://modrinth.com/project/hungerbridge) on the Minecraft server you wish to monitor
|
|
16
|
+
- HungerBridge supports `Fabric`, `Quilt`, `Paper`, `Purpur`, and `Folia`
|
|
17
|
+
**A dedicated Python environment**
|
|
18
|
+
- ServerWatcher requires a Python 3.14+ environment to run
|
|
19
|
+
*HungerNet Bot*
|
|
20
|
+
- Optional. Configure its webhook endpoint and shared token in `config/config.yaml`.
|
|
21
|
+
*Logging directory*
|
|
22
|
+
- Optional. Only necessary if you want to use file logging.
|
|
23
|
+
|
|
24
|
+
## Installation
|
|
25
|
+
- 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.
|
|
26
|
+
- Run the installer. It checks out the configured Git branch and installs `uv`; Python dependencies are synced on startup.
|
|
27
|
+
- Start the server once to create the empty `config/` directory. Add the required panel/server credentials as local overrides in `config/config.yaml`, then restart.
|
|
28
|
+
- On startup, missing override files silently use their packaged defaults. The example panel and API credentials are placeholders, so valid credentials are required before the watcher can connect.
|
|
29
|
+
- Subsequent starts update the checkout when `AUTO_UPDATE` is enabled, sync the Python environment, and run ServerWatcher.
|
|
30
|
+
|
|
31
|
+
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.
|
|
32
|
+
|
|
33
|
+
Defaults are loaded directly from the packaged YAML files in `src/serverwatcher/defaultconfigs/`; ServerWatcher does not copy them into the project directory. To override settings, create a matching YAML file under `config/` with only the values you want to change. MapRes merges those overrides over packaged defaults. `config/config.yaml` overrides server/API and logging settings; `evaluation.yaml`, `messages.yaml`, and `watcher.yaml` override their corresponding settings.
|
|
34
|
+
|
|
35
|
+
## HungerNet Bot Webhook
|
|
36
|
+
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:
|
|
37
|
+
|
|
38
|
+
```yaml
|
|
39
|
+
hungernetbot:
|
|
40
|
+
enabled: True
|
|
41
|
+
url: 'https://bot.example.com/webhook'
|
|
42
|
+
token: 'replace-with-the-shared-webhook-token'
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
The webhook reports restart scheduling and outcomes, sampling failures, and startup validation or unexpected errors. Leave it disabled if no HungerNet Bot receiver is configured.
|
|
@@ -7,10 +7,10 @@ build-backend = "setuptools.build_meta"
|
|
|
7
7
|
|
|
8
8
|
[project]
|
|
9
9
|
name = "serverwatcher"
|
|
10
|
-
version = "1"
|
|
11
|
-
description = "A
|
|
10
|
+
version = "1-dev.4"
|
|
11
|
+
description = "A HungerCore-powered Minecraft server automation engine."
|
|
12
12
|
readme = "README.md"
|
|
13
|
-
requires-python = ">=3.
|
|
13
|
+
requires-python = ">=3.14"
|
|
14
14
|
authors = [
|
|
15
15
|
{ name = "iFamished" },
|
|
16
16
|
]
|
|
@@ -18,21 +18,23 @@ keywords = [
|
|
|
18
18
|
"pterodactyl",
|
|
19
19
|
"minecraft",
|
|
20
20
|
"automation",
|
|
21
|
-
"rcon",
|
|
22
21
|
"server-management",
|
|
23
|
-
"
|
|
22
|
+
"hungercore",
|
|
24
23
|
"hungernet",
|
|
25
24
|
]
|
|
26
25
|
dependencies = [
|
|
27
|
-
"
|
|
28
|
-
"
|
|
26
|
+
"calagoapi",
|
|
27
|
+
"calagoapi-minecraft",
|
|
28
|
+
"hungerbridge",
|
|
29
|
+
"hungercore",
|
|
30
|
+
"mapres",
|
|
29
31
|
]
|
|
30
32
|
classifiers = [
|
|
31
33
|
"Programming Language :: Python :: 3",
|
|
32
34
|
"Programming Language :: Python :: 3.10",
|
|
33
35
|
"Programming Language :: Python :: 3.11",
|
|
34
36
|
"Programming Language :: Python :: 3.12",
|
|
35
|
-
"License :: OSI Approved ::
|
|
37
|
+
"License :: OSI Approved :: GNU General Public License v3 (GPLv3)",
|
|
36
38
|
"Operating System :: OS Independent",
|
|
37
39
|
"Development Status :: 4 - Beta",
|
|
38
40
|
"Intended Audience :: Developers",
|
|
@@ -41,15 +43,23 @@ classifiers = [
|
|
|
41
43
|
]
|
|
42
44
|
|
|
43
45
|
[project.license]
|
|
44
|
-
text = "
|
|
46
|
+
text = "GPL-3.0"
|
|
45
47
|
|
|
46
48
|
[project.urls]
|
|
47
|
-
Homepage = "https://github.com/
|
|
48
|
-
Documentation = "https://github.com/
|
|
49
|
-
Source = "https://github.com/
|
|
50
|
-
Issues = "https://github.com/
|
|
49
|
+
Homepage = "https://github.com/iFamished/ServerWatcher"
|
|
50
|
+
Documentation = "https://github.com/iFamished/ServerWatcher"
|
|
51
|
+
Source = "https://github.com/iFamished/ServerWatcher"
|
|
52
|
+
Issues = "https://github.com/iFamished/ServerWatcher/issues"
|
|
53
|
+
|
|
54
|
+
[project.scripts]
|
|
55
|
+
serverwatcher = "serverwatcher.app:main"
|
|
51
56
|
|
|
52
57
|
[tool.setuptools.packages.find]
|
|
53
58
|
where = [
|
|
54
59
|
"src",
|
|
55
60
|
]
|
|
61
|
+
|
|
62
|
+
[tool.setuptools.package-data]
|
|
63
|
+
serverwatcher = [
|
|
64
|
+
"defaultconfigs/*.yaml",
|
|
65
|
+
]
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
from importlib.metadata import version as _pkg_version, PackageNotFoundError
|
|
2
|
+
|
|
3
|
+
# Package version
|
|
4
|
+
try:
|
|
5
|
+
__version__ = _pkg_version('serverwatcher')
|
|
6
|
+
except PackageNotFoundError:
|
|
7
|
+
__version__ = '0.0.0'
|
|
8
|
+
|
|
9
|
+
from serverwatcher.watcher import ServerWatcher
|
|
10
|
+
from serverwatcher.configclasses.config import GlobalConfig
|
|
11
|
+
from serverwatcher.configclasses.watcher import WatcherConfig
|
|
12
|
+
|
|
13
|
+
__all__: list[str] = [
|
|
14
|
+
'ServerWatcher',
|
|
15
|
+
'GlobalConfig',
|
|
16
|
+
'WatcherConfig',
|
|
17
|
+
]
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import time
|
|
2
|
+
from zoneinfo import ZoneInfo
|
|
3
|
+
from hungercore import utils
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class ActionPerformer:
|
|
7
|
+
'''
|
|
8
|
+
Executes actions chosen by ServerWatcher:
|
|
9
|
+
- restart_now
|
|
10
|
+
- schedule_restart
|
|
11
|
+
- none
|
|
12
|
+
'''
|
|
13
|
+
|
|
14
|
+
def __init__(self, server, router, webhook, config):
|
|
15
|
+
self.server = server
|
|
16
|
+
self.router = router
|
|
17
|
+
self.webhook = webhook
|
|
18
|
+
self.cfg = config
|
|
19
|
+
self.tz = ZoneInfo(getattr(self.cfg, 'timezone', 'UTC'))
|
|
20
|
+
|
|
21
|
+
# public entry point
|
|
22
|
+
def perform(self, action: str, **ctx):
|
|
23
|
+
if action == 'restart_now':
|
|
24
|
+
return self._restart_now()
|
|
25
|
+
|
|
26
|
+
if action == 'schedule_restart':
|
|
27
|
+
minutes = ctx.get('minutes')
|
|
28
|
+
return self._schedule_restart(minutes)
|
|
29
|
+
|
|
30
|
+
if action == 'none':
|
|
31
|
+
return self._no_action()
|
|
32
|
+
|
|
33
|
+
raise ValueError(f'Unknown action: {action}')
|
|
34
|
+
|
|
35
|
+
def notifyWebhook(self, event: str, **ctx):
|
|
36
|
+
if self.webhook is not None:
|
|
37
|
+
self.webhook.send(event=event, **ctx)
|
|
38
|
+
|
|
39
|
+
# immediate restart
|
|
40
|
+
def _restart_now(self):
|
|
41
|
+
self.router.info('Performing immediate restart...')
|
|
42
|
+
self.notifyWebhook(event='restart_now')
|
|
43
|
+
|
|
44
|
+
# send restart command
|
|
45
|
+
self.server.restartServer()
|
|
46
|
+
self.router.info('Restart action sent. Waiting...')
|
|
47
|
+
self.notifyWebhook(event='restart_action_sent')
|
|
48
|
+
|
|
49
|
+
# wait before checking status
|
|
50
|
+
time.sleep(self.cfg.restart_wait_seconds)
|
|
51
|
+
|
|
52
|
+
self.router.warn('Checking server status...')
|
|
53
|
+
|
|
54
|
+
alive = utils.waitForOnline(
|
|
55
|
+
self.server,
|
|
56
|
+
timeout=self.cfg.restart_timeout,
|
|
57
|
+
interval=self.cfg.restart_online_interval,
|
|
58
|
+
)
|
|
59
|
+
|
|
60
|
+
if alive:
|
|
61
|
+
self.router.info('Server is back online!')
|
|
62
|
+
self.router.destination('ServerWatcher successfully restarted the server.')
|
|
63
|
+
self.notifyWebhook(event='server_back_online')
|
|
64
|
+
else:
|
|
65
|
+
self.router.error('Server failed to restart!')
|
|
66
|
+
self.notifyWebhook(event='server_failed_restart')
|
|
67
|
+
|
|
68
|
+
return alive
|
|
69
|
+
|
|
70
|
+
# scheduled restart (with snapping)
|
|
71
|
+
def _schedule_restart(self, minutes):
|
|
72
|
+
self.router.info('Scheduling restart...')
|
|
73
|
+
|
|
74
|
+
info = utils.snapSchedule(
|
|
75
|
+
minimumMinutes=minutes,
|
|
76
|
+
snapMinutes=tuple(sorted(self.cfg.snap_minutes))
|
|
77
|
+
)
|
|
78
|
+
scheduled = info['scheduled']
|
|
79
|
+
|
|
80
|
+
local_time = scheduled.astimezone(self.tz)
|
|
81
|
+
time_str = local_time.strftime('%I:%M %p')
|
|
82
|
+
|
|
83
|
+
# broadcast restart time
|
|
84
|
+
self.router.broadcast(f'[Server Watcher] The server will restart at {time_str} CDT.')
|
|
85
|
+
self.notifyWebhook(event='restart_scheduled', time=time_str)
|
|
86
|
+
|
|
87
|
+
# build minute + second callbacks
|
|
88
|
+
minute_callbacks = self._build_minute_callbacks()
|
|
89
|
+
second_callbacks = self._build_second_callbacks()
|
|
90
|
+
|
|
91
|
+
# run countdown
|
|
92
|
+
utils.runCountdownEvents(
|
|
93
|
+
target_time=scheduled,
|
|
94
|
+
minute_callbacks=minute_callbacks,
|
|
95
|
+
second_callbacks=second_callbacks
|
|
96
|
+
)
|
|
97
|
+
|
|
98
|
+
# After countdown, perform restart
|
|
99
|
+
return self._restart_now()
|
|
100
|
+
|
|
101
|
+
# no action
|
|
102
|
+
def _no_action(self):
|
|
103
|
+
self.router.info('No restart required.')
|
|
104
|
+
self.notifyWebhook(event='no_action')
|
|
105
|
+
return True
|
|
106
|
+
|
|
107
|
+
# helpers for countdown events
|
|
108
|
+
def _build_minute_callbacks(self):
|
|
109
|
+
'''
|
|
110
|
+
Creates callbacks for minute announcements.
|
|
111
|
+
Example: 'Restart in 30 minutes', 'Restart in 1 minute'
|
|
112
|
+
'''
|
|
113
|
+
def plural(n):
|
|
114
|
+
return '' if n == 1 else 's'
|
|
115
|
+
|
|
116
|
+
def minute_msg(n):
|
|
117
|
+
return f'[Server Watcher] Restart in {n} minute{plural(n)}!'
|
|
118
|
+
|
|
119
|
+
callbacks = {
|
|
120
|
+
n: (lambda n=n: (
|
|
121
|
+
self.router.broadcast(minute_msg(n + 1)),
|
|
122
|
+
self.router.origin(minute_msg(n + 1))
|
|
123
|
+
))
|
|
124
|
+
for n in self.cfg.snap_minutes
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
return callbacks
|
|
128
|
+
|
|
129
|
+
def _build_second_callbacks(self):
|
|
130
|
+
'''
|
|
131
|
+
Creates callbacks for final 10-second countdown.
|
|
132
|
+
'''
|
|
133
|
+
def plural(n):
|
|
134
|
+
return '' if n == 1 else 's'
|
|
135
|
+
|
|
136
|
+
def second_msg(n):
|
|
137
|
+
return f'[Server Watcher] Restarting in {n} second{plural(n)}!'
|
|
138
|
+
|
|
139
|
+
callbacks = {
|
|
140
|
+
n: (lambda n=n: (
|
|
141
|
+
self.router.broadcast(second_msg(n)),
|
|
142
|
+
self.router.origin(second_msg(n))
|
|
143
|
+
))
|
|
144
|
+
for n in range(1, 11)
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
return callbacks
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
from .config import GlobalConfig
|
|
2
|
+
from .discord import DiscordConfig
|
|
3
|
+
from .environment import EnvironmentConfig
|
|
4
|
+
from .evaluation import EvaluatorConfig
|
|
5
|
+
from .watcher import WatcherConfig
|
|
6
|
+
|
|
7
|
+
__all__: list[str] = [
|
|
8
|
+
'GlobalConfig',
|
|
9
|
+
'DiscordConfig',
|
|
10
|
+
'EnvironmentConfig',
|
|
11
|
+
'EvaluatorConfig',
|
|
12
|
+
'WatcherConfig',
|
|
13
|
+
]
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
from mapres import datamap
|
|
2
|
+
|
|
3
|
+
@datamap.braces.config(recursive=True)
|
|
4
|
+
class GlobalConfig:
|
|
5
|
+
__user_config_path__ = 'config/config.yaml'
|
|
6
|
+
__default_config_path__ = 'defaultconfigs/config.yaml'
|
|
7
|
+
|
|
8
|
+
debug: bool = 'debug'
|
|
9
|
+
timezone: str = 'timezone'
|
|
10
|
+
|
|
11
|
+
server_name: str = 'server.name'
|
|
12
|
+
server_domain: str = 'server.domain'
|
|
13
|
+
server_port: int = 'server.port'
|
|
14
|
+
|
|
15
|
+
enable_logging: bool = 'logger.enabled'
|
|
16
|
+
logger_name: str = 'logger.name'
|
|
17
|
+
log_path: str = 'logger.log_path'
|
|
18
|
+
|
|
19
|
+
info_prefix: str = 'logger.prefixes.info'
|
|
20
|
+
warn_prefix: str = 'logger.prefixes.warn'
|
|
21
|
+
error_prefix: str = 'logger.prefixes.error'
|
|
22
|
+
fatal_prefix: str = 'logger.prefixes.fatal'
|
|
23
|
+
debug_prefix: str = 'logger.prefixes.debug'
|
|
24
|
+
|
|
25
|
+
clear_terminal: bool = 'terminal.enable_clearing'
|
|
26
|
+
handle_keyboard_interrupt: bool = 'terminal.handle_keyboard_interrupt'
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
class fallbacks:
|
|
30
|
+
debug = False
|
|
31
|
+
timezone = 'America/Chicago'
|
|
32
|
+
|
|
33
|
+
server_name = 'My SMP'
|
|
34
|
+
server_domain = 'mc.example.com'
|
|
35
|
+
server_port = 25565
|
|
36
|
+
|
|
37
|
+
enable_logging = True
|
|
38
|
+
logger_name = 'Server Watcher'
|
|
39
|
+
log_path = '/home/container/logs/'
|
|
40
|
+
|
|
41
|
+
info_prefix = '<white>[%hh%:%mm%:%ss%] [INFO]: '
|
|
42
|
+
warn_prefix = '<yellow>[%hh%:%mm%:%ss%] [WARN]: '
|
|
43
|
+
error_prefix = '<red>[%hh%:%mm%:%ss%] [ERROR]: '
|
|
44
|
+
fatal_prefix = '<dark_red>[%hh%:%mm%:%ss%] [FATAL]: '
|
|
45
|
+
debug_prefix = '<aqua>[%hh%:%mm%:%ss%] [DEBUG]: '
|
|
46
|
+
|
|
47
|
+
clear_terminal = True
|
|
48
|
+
handle_keyboard_interrupt = True
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
class rules:
|
|
52
|
+
pass # everything defaults to optional
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
from mapres import datamap
|
|
2
|
+
|
|
3
|
+
@datamap.braces.config(recursive=True)
|
|
4
|
+
class DiscordConfig:
|
|
5
|
+
__user_config_path__ = 'config/discord.yaml'
|
|
6
|
+
__default_config_path__ = 'defaultconfigs/discord.yaml'
|
|
7
|
+
|
|
8
|
+
discord_enabled: bool = 'discord.enabled'
|
|
9
|
+
discord_token: str = 'discord.token'
|
|
10
|
+
discord_url: str = 'discord.url'
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class fallbacks:
|
|
14
|
+
discord_enabled = True
|
|
15
|
+
discord_token = 'CHANGE_ME'
|
|
16
|
+
discord_url = 'https://bot.example.com/webhook'
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class rules:
|
|
20
|
+
discord_enabled = 'recommended'
|
|
21
|
+
discord_token = 'recommended'
|
|
22
|
+
discord_url = 'recommended'
|
|
23
|
+
# everything else defaults to optional
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
from mapres import datamap
|
|
2
|
+
|
|
3
|
+
@datamap.braces.config(recursive=True)
|
|
4
|
+
class EnvironmentConfig:
|
|
5
|
+
__user_config_path__ = 'config/environment.yaml'
|
|
6
|
+
__default_config_path__ = 'defaultconfigs/environment.yaml'
|
|
7
|
+
|
|
8
|
+
bridge_url: str = 'hungerbridge.url'
|
|
9
|
+
bridge_token_id: str = 'hungerbridge.token_id'
|
|
10
|
+
bridge_token_secret: str = 'hungerbridge.token_secret'
|
|
11
|
+
|
|
12
|
+
ptero_enabled: bool = 'pterodactyl.enabled'
|
|
13
|
+
ptero_url: str = 'pterodactyl.url'
|
|
14
|
+
ptero_api_key: str = 'pterodactyl.api_key'
|
|
15
|
+
ptero_server_id: str = 'pterodactyl.server_id'
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class fallbacks:
|
|
19
|
+
bridge_token_id = 'CHANGE_ME'
|
|
20
|
+
bridge_token_secret = 'CHANGE_ME'
|
|
21
|
+
bridge_url = 'https://api.example.com'
|
|
22
|
+
|
|
23
|
+
ptero_enabled = False
|
|
24
|
+
ptero_url = 'https://example.com'
|
|
25
|
+
ptero_api_key = 'CHANGE_ME'
|
|
26
|
+
ptero_server_id = 'CHANGE_ME'
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
class rules:
|
|
30
|
+
bridge_token_id = 'required'
|
|
31
|
+
bridge_token_secret = 'required'
|
|
32
|
+
bridge_url = 'required'
|
|
33
|
+
|
|
34
|
+
ptero_enabled = 'recommended'
|
|
35
|
+
ptero_url = 'recommended'
|
|
36
|
+
ptero_api_key = 'recommended'
|
|
37
|
+
ptero_server_id = 'recommended'
|
|
38
|
+
# everything else defaults to optional
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
from mapres import datamap
|
|
2
|
+
|
|
3
|
+
@datamap.braces.config(recursive=True)
|
|
4
|
+
class EvaluatorConfig:
|
|
5
|
+
__user_config_path__ = 'config/evaluation.yaml'
|
|
6
|
+
__default_config_path__ = 'defaultconfigs/evaluation.yaml'
|
|
7
|
+
|
|
8
|
+
# Sampling
|
|
9
|
+
sample_duration: float | int = 'sampling.duration'
|
|
10
|
+
sample_interval: float | int = 'sampling.interval'
|
|
11
|
+
sample_outlier_drop: int = 'sampling.drop_outliers'
|
|
12
|
+
|
|
13
|
+
# Thresholds
|
|
14
|
+
threshold_ram: float = 'thresholds.ram'
|
|
15
|
+
threshold_cpu: float = 'thresholds.cpu'
|
|
16
|
+
threshold_uptime: float = 'thresholds.uptime'
|
|
17
|
+
threshold_min_uptime: float = 'thresholds.min_uptime'
|
|
18
|
+
|
|
19
|
+
threshold_players: int = 'thresholds.players'
|
|
20
|
+
threshold_max_players: int = 'thresholds.max_players'
|
|
21
|
+
|
|
22
|
+
threshold_tps: float = 'thresholds.tps'
|
|
23
|
+
threshold_tps_1m: float = 'thresholds.tps_1m'
|
|
24
|
+
threshold_tps_5m: float = 'thresholds.tps_5m'
|
|
25
|
+
threshold_tps_15m: float = 'thresholds.tps_15m'
|
|
26
|
+
|
|
27
|
+
threshold_mspt: float = 'thresholds.mspt'
|
|
28
|
+
|
|
29
|
+
threshold_loaded_chunks: int = 'thresholds.loaded_chunks'
|
|
30
|
+
threshold_loaded_entities: int = 'thresholds.loaded_entities'
|
|
31
|
+
|
|
32
|
+
threshold_gc_pause_ms: float = 'thresholds.gc_pause_ms'
|
|
33
|
+
threshold_thread_peak: int = 'thresholds.thread_peak'
|
|
34
|
+
|
|
35
|
+
# Weights
|
|
36
|
+
weight_ram: int = 'weights.ram'
|
|
37
|
+
weight_cpu: int = 'weights.cpu'
|
|
38
|
+
weight_uptime: int = 'weights.uptime'
|
|
39
|
+
|
|
40
|
+
weight_players: int = 'weights.players'
|
|
41
|
+
weight_max_players: int = 'weights.max_players'
|
|
42
|
+
|
|
43
|
+
weight_tps: int = 'weights.tps'
|
|
44
|
+
weight_tps_1m: int = 'weights.tps_1m'
|
|
45
|
+
weight_tps_5m: int = 'weights.tps_5m'
|
|
46
|
+
weight_tps_15m: int = 'weights.tps_15m'
|
|
47
|
+
|
|
48
|
+
weight_mspt: int = 'weights.mspt'
|
|
49
|
+
|
|
50
|
+
weight_loaded_chunks: int = 'weights.loaded_chunks'
|
|
51
|
+
weight_loaded_entities: int = 'weights.loaded_entities'
|
|
52
|
+
|
|
53
|
+
weight_gc_pause_ms: int = 'weights.gc_pause_ms'
|
|
54
|
+
weight_thread_peak: int = 'weights.thread_peak'
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
class fallbacks:
|
|
58
|
+
sample_duration = 5
|
|
59
|
+
sample_interval = 1
|
|
60
|
+
sample_outlier_drop = 1
|
|
61
|
+
|
|
62
|
+
threshold_ram = 6
|
|
63
|
+
threshold_cpu = 150
|
|
64
|
+
threshold_uptime = 12
|
|
65
|
+
threshold_min_uptime = 30
|
|
66
|
+
|
|
67
|
+
threshold_players = 0
|
|
68
|
+
threshold_max_players = 0
|
|
69
|
+
|
|
70
|
+
threshold_tps = 19.5
|
|
71
|
+
threshold_tps_1m = 19.5
|
|
72
|
+
threshold_tps_5m = 19.5
|
|
73
|
+
threshold_tps_15m = 19.5
|
|
74
|
+
|
|
75
|
+
threshold_mspt = 50
|
|
76
|
+
|
|
77
|
+
threshold_loaded_chunks = 0
|
|
78
|
+
threshold_loaded_entities = 0
|
|
79
|
+
|
|
80
|
+
threshold_gc_pause_ms = 200
|
|
81
|
+
threshold_thread_peak = 500
|
|
82
|
+
|
|
83
|
+
weight_ram = 2
|
|
84
|
+
weight_cpu = 2
|
|
85
|
+
weight_uptime = 1
|
|
86
|
+
|
|
87
|
+
weight_players = 1
|
|
88
|
+
weight_max_players = 0
|
|
89
|
+
|
|
90
|
+
weight_tps = 3
|
|
91
|
+
weight_tps_1m = 1
|
|
92
|
+
weight_tps_5m = 1
|
|
93
|
+
weight_tps_15m = 1
|
|
94
|
+
|
|
95
|
+
weight_mspt = 3
|
|
96
|
+
|
|
97
|
+
weight_loaded_chunks = 0
|
|
98
|
+
weight_loaded_entities = 0
|
|
99
|
+
|
|
100
|
+
weight_gc_pause_ms = 2
|
|
101
|
+
weight_thread_peak = 2
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
class rules:
|
|
105
|
+
threshold_ram = 'required'
|
|
106
|
+
threshold_cpu = 'required'
|
|
107
|
+
threshold_tps = 'required'
|
|
108
|
+
threshold_mspt = 'required'
|
|
109
|
+
threshold_uptime = 'required'
|
|
110
|
+
threshold_min_uptime = 'required'
|