serverwatcher 5.33.dev4__py3-none-any.whl → 6.dev2__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/__main__.py +71 -17
- serverwatcher/cli.py +385 -0
- serverwatcher/configclasses/config.py +14 -3
- serverwatcher/configclasses/messages.py +2 -2
- serverwatcher/configclasses/watcher.py +2 -2
- serverwatcher/defaultconfigs/config.yaml +6 -1
- serverwatcher/defaultconfigs/messages.yaml +21 -21
- serverwatcher/validator.py +14 -0
- serverwatcher/watcher.py +96 -21
- serverwatcher-6.dev2.dist-info/METADATA +62 -0
- serverwatcher-6.dev2.dist-info/RECORD +17 -0
- {serverwatcher-5.33.dev4.dist-info → serverwatcher-6.dev2.dist-info}/WHEEL +1 -1
- serverwatcher-5.33.dev4.dist-info/METADATA +0 -47
- serverwatcher-5.33.dev4.dist-info/RECORD +0 -16
- {serverwatcher-5.33.dev4.dist-info → serverwatcher-6.dev2.dist-info}/licenses/LICENSE +0 -0
- {serverwatcher-5.33.dev4.dist-info → serverwatcher-6.dev2.dist-info}/top_level.txt +0 -0
serverwatcher/__main__.py
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
from
|
|
2
|
-
|
|
1
|
+
from mapres import rprint, setGlobalMaps, ascii_colors
|
|
2
|
+
import time
|
|
3
|
+
import asyncio
|
|
4
|
+
import threading
|
|
5
|
+
from .cli import WatcherCLI
|
|
6
|
+
|
|
3
7
|
from hungerlib.validator import (
|
|
4
8
|
ValidationError,
|
|
5
9
|
FatalError,
|
|
@@ -7,41 +11,91 @@ from hungerlib.validator import (
|
|
|
7
11
|
FallbackError,
|
|
8
12
|
RecommendedError,
|
|
9
13
|
)
|
|
10
|
-
import time
|
|
11
14
|
|
|
15
|
+
from .watcher import ServerWatcher
|
|
16
|
+
from .validator import validate_all
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
# mapres setup
|
|
20
|
+
setGlobalMaps(ascii_colors)
|
|
21
|
+
|
|
22
|
+
# pretty printer for validator reports
|
|
23
|
+
def pretty_report(report: str) -> str:
|
|
24
|
+
lines = report.splitlines()
|
|
25
|
+
out = []
|
|
26
|
+
for line in lines:
|
|
27
|
+
stripped = line.strip()
|
|
28
|
+
if stripped.startswith('errors:'):
|
|
29
|
+
out.append('<red>Errors:')
|
|
30
|
+
continue
|
|
31
|
+
if stripped.startswith('recommended:'):
|
|
32
|
+
out.append('<yellow>Recommended:')
|
|
33
|
+
continue
|
|
34
|
+
if stripped.startswith('fallbacks:'):
|
|
35
|
+
out.append('<yellow>Fallbacks:')
|
|
36
|
+
continue
|
|
37
|
+
if stripped.startswith('warnings:'):
|
|
38
|
+
out.append('<aqua>Warnings:')
|
|
39
|
+
continue
|
|
40
|
+
if stripped.startswith('- '):
|
|
41
|
+
out.append(f' {stripped}')
|
|
42
|
+
continue
|
|
43
|
+
out.append(line)
|
|
44
|
+
return '\n'.join(out)
|
|
45
|
+
|
|
46
|
+
# main function
|
|
12
47
|
def main():
|
|
13
48
|
try:
|
|
14
49
|
validate_all()
|
|
15
50
|
|
|
16
51
|
except FatalError as e:
|
|
17
|
-
|
|
18
|
-
|
|
52
|
+
rprint('<bold><red>FATAL CONFIG ERROR:')
|
|
53
|
+
rprint(pretty_report(e.report))
|
|
54
|
+
rprint('\nIt looks like ServerWatcher is not configured yet.')
|
|
55
|
+
rprint('<aqua>Please edit your config files in config/ and try again.')
|
|
19
56
|
return
|
|
20
57
|
|
|
21
58
|
except TypeMismatchError as e:
|
|
22
|
-
|
|
23
|
-
|
|
59
|
+
rprint('<bold><red>TYPE MISMATCH ERROR:')
|
|
60
|
+
rprint(pretty_report(e.report))
|
|
61
|
+
rprint('\nYour configuration contains values of the wrong type.')
|
|
62
|
+
rprint('<aqua>Please fix your config files and try again.')
|
|
24
63
|
return
|
|
25
64
|
|
|
26
65
|
except FallbackError as e:
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
66
|
+
rprint('<bold><yellow>FALLBACKS IN USE:')
|
|
67
|
+
rprint(pretty_report(e.report))
|
|
68
|
+
rprint('\nIt looks like you have not configured ServerWatcher yet.')
|
|
69
|
+
rprint('<aqua>Please edit your config files in config/ and try again.')
|
|
70
|
+
return
|
|
31
71
|
|
|
32
72
|
except RecommendedError as e:
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
73
|
+
rprint('<bold><yellow>RECOMMENDED KEYS MISSING:')
|
|
74
|
+
rprint(pretty_report(e.report))
|
|
75
|
+
rprint('\nYour configuration is missing recommended keys.')
|
|
76
|
+
rprint('<aqua>Continuing in 5 seconds...')
|
|
36
77
|
time.sleep(5)
|
|
37
78
|
|
|
38
79
|
except ValidationError as e:
|
|
39
|
-
|
|
40
|
-
|
|
80
|
+
rprint('<bold><red>CONFIG ERROR:')
|
|
81
|
+
rprint(pretty_report(e.report))
|
|
82
|
+
rprint('\nYour configuration is invalid.')
|
|
83
|
+
rprint('<aqua>Please edit your config files and try again.')
|
|
84
|
+
return
|
|
85
|
+
|
|
86
|
+
except Exception as e:
|
|
87
|
+
rprint('<bold><red>UNEXPECTED ERROR:')
|
|
88
|
+
rprint(str(e))
|
|
89
|
+
rprint('\nSomething went wrong before ServerWatcher could start.')
|
|
90
|
+
rprint('<aqua>Please check your configuration and environment.')
|
|
41
91
|
return
|
|
42
92
|
|
|
93
|
+
# if validation passes, start ServerWatcher
|
|
43
94
|
watcher = ServerWatcher()
|
|
44
|
-
watcher.run()
|
|
95
|
+
threading.Thread(target=watcher.run, daemon=True).start()
|
|
96
|
+
|
|
97
|
+
cli = WatcherCLI(watcher)
|
|
98
|
+
asyncio.run(cli.run())
|
|
45
99
|
|
|
46
100
|
if __name__ == '__main__':
|
|
47
101
|
main()
|
serverwatcher/cli.py
ADDED
|
@@ -0,0 +1,385 @@
|
|
|
1
|
+
import asyncio
|
|
2
|
+
import cmd
|
|
3
|
+
import sys
|
|
4
|
+
import termios
|
|
5
|
+
import tty
|
|
6
|
+
from dataclasses import dataclass
|
|
7
|
+
|
|
8
|
+
from hungerlib import utils
|
|
9
|
+
from mapres import res, maps, setGlobalMaps
|
|
10
|
+
from .watcher import ServerWatcher
|
|
11
|
+
|
|
12
|
+
setGlobalMaps(maps.ascii_colors)
|
|
13
|
+
|
|
14
|
+
# ARGUMENT PARSING ENGINE
|
|
15
|
+
COMMANDS: dict[str, callable] = {}
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
@dataclass
|
|
19
|
+
class ParsedArgs:
|
|
20
|
+
subcommand: str | None
|
|
21
|
+
positional: list[str]
|
|
22
|
+
flags: dict[str, bool]
|
|
23
|
+
params: dict[str, str]
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def parse_line(raw: str) -> ParsedArgs:
|
|
27
|
+
raw = raw.strip()
|
|
28
|
+
if not raw:
|
|
29
|
+
return ParsedArgs(None, [], {}, {})
|
|
30
|
+
|
|
31
|
+
parts = raw.split()
|
|
32
|
+
sub = parts[0]
|
|
33
|
+
positional: list[str] = []
|
|
34
|
+
flags: dict[str, bool] = {}
|
|
35
|
+
params: dict[str, str] = {}
|
|
36
|
+
|
|
37
|
+
for token in parts[1:]:
|
|
38
|
+
if token.startswith('--'):
|
|
39
|
+
flags[token[2:]] = True
|
|
40
|
+
elif ':' in token:
|
|
41
|
+
key, value = token.split(':', 1)
|
|
42
|
+
params[key.lower()] = value
|
|
43
|
+
else:
|
|
44
|
+
positional.append(token)
|
|
45
|
+
|
|
46
|
+
return ParsedArgs(sub, positional, flags, params)
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
@dataclass
|
|
50
|
+
class ArgSpec:
|
|
51
|
+
name: str
|
|
52
|
+
kind: str # 'flag' or 'param'
|
|
53
|
+
type: callable = str
|
|
54
|
+
default: object = None
|
|
55
|
+
func: callable | None = None
|
|
56
|
+
present: bool = False
|
|
57
|
+
raw_value: str | None = None
|
|
58
|
+
|
|
59
|
+
def __call__(self):
|
|
60
|
+
if not self.present:
|
|
61
|
+
return self.default
|
|
62
|
+
if self.kind == 'flag':
|
|
63
|
+
return True
|
|
64
|
+
if self.raw_value is None:
|
|
65
|
+
return self.default
|
|
66
|
+
return self.type(self.raw_value)
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
class CommandContext:
|
|
70
|
+
def __init__(self, parsed: ParsedArgs):
|
|
71
|
+
self.parsed = parsed
|
|
72
|
+
self.arg_specs: dict[str, ArgSpec] = {}
|
|
73
|
+
self.child_name: str | None = None
|
|
74
|
+
self.child_func: callable | None = None
|
|
75
|
+
|
|
76
|
+
def register_param(self, name: str, type_: callable, default: object, func: callable) -> ArgSpec:
|
|
77
|
+
spec = ArgSpec(name=name, kind='param', type=type_, default=default, func=func)
|
|
78
|
+
self.arg_specs[name] = spec
|
|
79
|
+
return spec
|
|
80
|
+
|
|
81
|
+
def register_flag(self, name: str, func: callable) -> ArgSpec:
|
|
82
|
+
spec = ArgSpec(name=name, kind='flag', default=False, func=func)
|
|
83
|
+
self.arg_specs[name] = spec
|
|
84
|
+
return spec
|
|
85
|
+
|
|
86
|
+
def register_child(self, name: str, func: callable) -> callable:
|
|
87
|
+
self.child_name = name
|
|
88
|
+
self.child_func = func
|
|
89
|
+
return func
|
|
90
|
+
|
|
91
|
+
def bind(self) -> None:
|
|
92
|
+
for name, spec in self.arg_specs.items():
|
|
93
|
+
if spec.kind == 'flag' and name in self.parsed.flags:
|
|
94
|
+
spec.present = True
|
|
95
|
+
|
|
96
|
+
for name, spec in self.arg_specs.items():
|
|
97
|
+
if spec.kind == 'param' and name in self.parsed.params:
|
|
98
|
+
spec.present = True
|
|
99
|
+
spec.raw_value = self.parsed.params[name]
|
|
100
|
+
|
|
101
|
+
def positional(self, index: int, default: object = None) -> object:
|
|
102
|
+
try:
|
|
103
|
+
return self.parsed.positional[index]
|
|
104
|
+
except IndexError:
|
|
105
|
+
return default
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
# decorators
|
|
109
|
+
def command(name: str):
|
|
110
|
+
def decorator(func: callable):
|
|
111
|
+
COMMANDS[name] = func
|
|
112
|
+
return func
|
|
113
|
+
return decorator
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
def child(name: str):
|
|
117
|
+
def decorator(func: callable):
|
|
118
|
+
func.__child_name__ = name
|
|
119
|
+
return func
|
|
120
|
+
return decorator
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
def param(name: str, type: callable = str, default: object = None):
|
|
124
|
+
def decorator(func: callable):
|
|
125
|
+
func.__arg_kind__ = 'param'
|
|
126
|
+
func.__arg_name__ = name
|
|
127
|
+
func.__arg_type__ = type
|
|
128
|
+
func.__arg_default__ = default
|
|
129
|
+
return func
|
|
130
|
+
return decorator
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
def flag(name: str):
|
|
134
|
+
def decorator(func: callable):
|
|
135
|
+
func.__arg_kind__ = 'flag'
|
|
136
|
+
func.__arg_name__ = name
|
|
137
|
+
return func
|
|
138
|
+
return decorator
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
# DISPATCHER
|
|
142
|
+
class CLIBase:
|
|
143
|
+
def safePrint(self, msg: object = '', end: str = '\n') -> None:
|
|
144
|
+
print(str(msg), end=end)
|
|
145
|
+
|
|
146
|
+
def bprint(self, msg: object) -> None:
|
|
147
|
+
self.safePrint(msg)
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
def dispatch(cli: CLIBase, line: str):
|
|
151
|
+
parsed = parse_line(line)
|
|
152
|
+
if not parsed.subcommand:
|
|
153
|
+
return
|
|
154
|
+
|
|
155
|
+
handler = COMMANDS.get(parsed.subcommand)
|
|
156
|
+
if handler is None:
|
|
157
|
+
cli.safePrint(f'Unknown command \'{parsed.subcommand}\'')
|
|
158
|
+
return
|
|
159
|
+
|
|
160
|
+
ctx = CommandContext(parsed)
|
|
161
|
+
|
|
162
|
+
# Register decorators
|
|
163
|
+
handler(cli, ctx)
|
|
164
|
+
|
|
165
|
+
# Bind parsed values
|
|
166
|
+
ctx.bind()
|
|
167
|
+
|
|
168
|
+
# Execute child command
|
|
169
|
+
if ctx.child_func:
|
|
170
|
+
stat = ctx.positional(0)
|
|
171
|
+
return ctx.child_func(stat)
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
# CLI Implementation
|
|
175
|
+
class BufferingStdout:
|
|
176
|
+
def __init__(self, buffer, real_stdout):
|
|
177
|
+
self.buffer = buffer
|
|
178
|
+
self.real_stdout = real_stdout
|
|
179
|
+
|
|
180
|
+
def write(self, text: str) -> None:
|
|
181
|
+
if self.buffer.enabled and text.strip():
|
|
182
|
+
self.buffer.captured.append(text.rstrip('\n'))
|
|
183
|
+
self.real_stdout.write(text)
|
|
184
|
+
|
|
185
|
+
def flush(self) -> None:
|
|
186
|
+
self.real_stdout.flush()
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
class WatcherCLI(cmd.Cmd, CLIBase):
|
|
190
|
+
prompt = ''
|
|
191
|
+
|
|
192
|
+
def __init__(self, watcher: ServerWatcher):
|
|
193
|
+
self.watcher = watcher
|
|
194
|
+
self.buffer = utils.Buffer(enabled=True)
|
|
195
|
+
self.real_stdout = sys.stdout
|
|
196
|
+
self.cli_stdout = BufferingStdout(self.buffer, self.real_stdout)
|
|
197
|
+
super().__init__(stdout=self.cli_stdout)
|
|
198
|
+
self.outputMode = 'both'
|
|
199
|
+
self.use_rawinput = False
|
|
200
|
+
|
|
201
|
+
def read_line_raw(self) -> str:
|
|
202
|
+
fd = sys.stdin.fileno()
|
|
203
|
+
old = termios.tcgetattr(fd)
|
|
204
|
+
try:
|
|
205
|
+
tty.setraw(fd)
|
|
206
|
+
chars: list[str] = []
|
|
207
|
+
while True:
|
|
208
|
+
ch = sys.stdin.read(1)
|
|
209
|
+
if ch in ('\r', '\n'):
|
|
210
|
+
break
|
|
211
|
+
chars.append(ch)
|
|
212
|
+
return ''.join(chars)
|
|
213
|
+
finally:
|
|
214
|
+
termios.tcsetattr(fd, termios.TCSADRAIN, old)
|
|
215
|
+
|
|
216
|
+
async def run(self):
|
|
217
|
+
while True:
|
|
218
|
+
try:
|
|
219
|
+
line = await asyncio.to_thread(self.read_line_raw)
|
|
220
|
+
line = line.strip()
|
|
221
|
+
if not line:
|
|
222
|
+
continue
|
|
223
|
+
if self.buffer.enabled and not line.startswith('view'):
|
|
224
|
+
self.buffer.captured.append(line)
|
|
225
|
+
stop = await asyncio.to_thread(self.onecmd, line)
|
|
226
|
+
if stop:
|
|
227
|
+
break
|
|
228
|
+
except KeyboardInterrupt:
|
|
229
|
+
if self.watcher.config.handle_keyboard_interrupt:
|
|
230
|
+
self.watcher.shutdown()
|
|
231
|
+
return
|
|
232
|
+
else:
|
|
233
|
+
raise
|
|
234
|
+
|
|
235
|
+
def onecmd(self, line: str):
|
|
236
|
+
return dispatch(self, line)
|
|
237
|
+
|
|
238
|
+
def printHeader(self) -> None:
|
|
239
|
+
self.safePrint(res('<yellow>-----------------------------------'))
|
|
240
|
+
self.safePrint(res('<yellow>-------- <aqua>ServerWatcher CLI <yellow>--------'))
|
|
241
|
+
self.safePrint(res('<yellow>-----------------------------------'))
|
|
242
|
+
self.safePrint('\n')
|
|
243
|
+
|
|
244
|
+
|
|
245
|
+
# commands
|
|
246
|
+
@command('stats')
|
|
247
|
+
def stats(self: WatcherCLI, ctx: CommandContext):
|
|
248
|
+
|
|
249
|
+
@child('get')
|
|
250
|
+
def get(stat: str):
|
|
251
|
+
|
|
252
|
+
@param('rounding', type=int, default=2)
|
|
253
|
+
def rounding(value: int) -> int:
|
|
254
|
+
return value
|
|
255
|
+
|
|
256
|
+
@param('mode', default='current')
|
|
257
|
+
def mode(value: str) -> str:
|
|
258
|
+
return value
|
|
259
|
+
|
|
260
|
+
@flag('raw')
|
|
261
|
+
def raw() -> bool:
|
|
262
|
+
return False
|
|
263
|
+
|
|
264
|
+
@flag('formatted')
|
|
265
|
+
def formatted() -> bool:
|
|
266
|
+
return True
|
|
267
|
+
|
|
268
|
+
@flag('no-formatted')
|
|
269
|
+
def no_formatted() -> bool:
|
|
270
|
+
return False
|
|
271
|
+
|
|
272
|
+
# extract specs
|
|
273
|
+
r = ctx.arg_specs['rounding']
|
|
274
|
+
m = ctx.arg_specs['mode']
|
|
275
|
+
raw_f = ctx.arg_specs['raw']
|
|
276
|
+
fmt_f = ctx.arg_specs['formatted']
|
|
277
|
+
nofmt_f = ctx.arg_specs['no-formatted']
|
|
278
|
+
|
|
279
|
+
rounding_val = r()
|
|
280
|
+
mode_val = m()
|
|
281
|
+
|
|
282
|
+
gb: bool = False if raw_f.present else True
|
|
283
|
+
|
|
284
|
+
if fmt_f.present:
|
|
285
|
+
fmt: bool = True
|
|
286
|
+
elif nofmt_f.present:
|
|
287
|
+
fmt = False
|
|
288
|
+
else:
|
|
289
|
+
fmt = True
|
|
290
|
+
|
|
291
|
+
self.watcher.server.refresh()
|
|
292
|
+
|
|
293
|
+
unit: str = ''
|
|
294
|
+
match stat:
|
|
295
|
+
case 'ram':
|
|
296
|
+
value = self.watcher.server.getRAM(rounding=rounding_val, gb=gb)
|
|
297
|
+
name = 'RAM'
|
|
298
|
+
unit = ' GB' if gb else ' MB'
|
|
299
|
+
case 'cpu':
|
|
300
|
+
value = self.watcher.server.getCPU(rounding=rounding_val)
|
|
301
|
+
name = 'CPU'
|
|
302
|
+
unit = '%'
|
|
303
|
+
case 'uptime':
|
|
304
|
+
value = self.watcher.server.getUptime(formatted=fmt)
|
|
305
|
+
name = 'Uptime'
|
|
306
|
+
unit = '' if fmt else 'ms'
|
|
307
|
+
case 'tps':
|
|
308
|
+
value = self.watcher.server.getTPS(rounding=rounding_val, mode=mode_val)
|
|
309
|
+
name = 'TPS'
|
|
310
|
+
case 'players':
|
|
311
|
+
value = self.watcher.server.getPlayers()
|
|
312
|
+
name = 'Players'
|
|
313
|
+
case 'version':
|
|
314
|
+
value = self.watcher.server.version
|
|
315
|
+
name = 'Minecraft version'
|
|
316
|
+
case 'platform':
|
|
317
|
+
value = self.watcher.server.platform
|
|
318
|
+
name = 'Server platform'
|
|
319
|
+
case _:
|
|
320
|
+
return self.safePrint('Unknown stat')
|
|
321
|
+
|
|
322
|
+
self.bprint(f'{name}: {value}{unit}')
|
|
323
|
+
|
|
324
|
+
|
|
325
|
+
@command('view')
|
|
326
|
+
def view(self: WatcherCLI, ctx: CommandContext):
|
|
327
|
+
|
|
328
|
+
@child('cli')
|
|
329
|
+
def cli_view(_):
|
|
330
|
+
self.watcher.router.disableOriginOutput()
|
|
331
|
+
self.outputMode = 'cli'
|
|
332
|
+
self.buffer.enabled = True
|
|
333
|
+
utils.clearTerminal()
|
|
334
|
+
self.printHeader()
|
|
335
|
+
for msg in self.buffer.captured:
|
|
336
|
+
self.safePrint(msg)
|
|
337
|
+
|
|
338
|
+
@child('watcher')
|
|
339
|
+
def watcher_view(_):
|
|
340
|
+
self.watcher.router.enableOriginOutput()
|
|
341
|
+
self.outputMode = 'both'
|
|
342
|
+
utils.clearTerminal()
|
|
343
|
+
self.printHeader()
|
|
344
|
+
for msg in self.watcher.router.buffer.captured:
|
|
345
|
+
self.safePrint(msg)
|
|
346
|
+
|
|
347
|
+
|
|
348
|
+
@command('clear')
|
|
349
|
+
def clear(self: WatcherCLI, ctx: CommandContext):
|
|
350
|
+
|
|
351
|
+
@param('buffer', type=str, default='true')
|
|
352
|
+
def buffer_param(value: str) -> bool:
|
|
353
|
+
return value.lower() == 'true'
|
|
354
|
+
|
|
355
|
+
buf = ctx.arg_specs['buffer']()
|
|
356
|
+
|
|
357
|
+
if buf:
|
|
358
|
+
self.buffer.clear()
|
|
359
|
+
|
|
360
|
+
utils.clearTerminal()
|
|
361
|
+
self.printHeader()
|
|
362
|
+
|
|
363
|
+
|
|
364
|
+
@command('watcher')
|
|
365
|
+
def watcher(self: WatcherCLI, ctx: CommandContext):
|
|
366
|
+
|
|
367
|
+
@child('restart')
|
|
368
|
+
def restart(_):
|
|
369
|
+
self.watcher.restart_and_wait()
|
|
370
|
+
|
|
371
|
+
@child('schedule')
|
|
372
|
+
def schedule(_):
|
|
373
|
+
minutes = ctx.positional(1)
|
|
374
|
+
if minutes is None:
|
|
375
|
+
return self.safePrint('Usage: watcher schedule <minutes>')
|
|
376
|
+
try:
|
|
377
|
+
minutes = int(minutes)
|
|
378
|
+
except ValueError:
|
|
379
|
+
return self.safePrint('Minutes must be an integer')
|
|
380
|
+
self.watcher.schedule_restart(minutes)
|
|
381
|
+
|
|
382
|
+
@child('shutdown')
|
|
383
|
+
def shutdown(_):
|
|
384
|
+
self.watcher.shutdown()
|
|
385
|
+
return True
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
from mapres import datamap
|
|
1
|
+
from mapres import datamap
|
|
2
2
|
|
|
3
|
-
@datamap
|
|
3
|
+
@datamap.braces.config(recursive=True)
|
|
4
4
|
class GlobalConfig:
|
|
5
5
|
__user_config_path__ = 'config/config.yaml'
|
|
6
6
|
__default_config_path__ = 'defaultconfigs/config.yaml'
|
|
@@ -20,6 +20,10 @@ class GlobalConfig:
|
|
|
20
20
|
bridge_token: str = 'hungerbridge.token'
|
|
21
21
|
bridge_url: str = 'hungerbridge.url'
|
|
22
22
|
|
|
23
|
+
discord_enabled: bool = 'discord.enabled'
|
|
24
|
+
discord_token: str = 'discord.token'
|
|
25
|
+
discord_url: str = 'discord.url'
|
|
26
|
+
|
|
23
27
|
enable_logging: bool = 'logger.enabled'
|
|
24
28
|
logger_name: str = 'logger.name'
|
|
25
29
|
log_path: str = 'logger.log_path'
|
|
@@ -47,7 +51,11 @@ class fallbacks:
|
|
|
47
51
|
server_port = 25565
|
|
48
52
|
|
|
49
53
|
bridge_token = 'CHANGE_ME'
|
|
50
|
-
bridge_url = 'https://api.example.com
|
|
54
|
+
bridge_url = 'https://api.example.com'
|
|
55
|
+
|
|
56
|
+
discord_enabled = True
|
|
57
|
+
discord_token = 'CHANGE_ME'
|
|
58
|
+
discord_url = 'https://bot.example.com/webhook'
|
|
51
59
|
|
|
52
60
|
enable_logging = True
|
|
53
61
|
logger_name = 'Server Watcher'
|
|
@@ -74,4 +82,7 @@ class rules:
|
|
|
74
82
|
server_port = 'recommended'
|
|
75
83
|
bridge_url = 'recommended'
|
|
76
84
|
|
|
85
|
+
discord_url = 'recommended'
|
|
86
|
+
discord_token = 'recommended'
|
|
87
|
+
|
|
77
88
|
# everything else defaults to optional
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
from mapres import datamap
|
|
1
|
+
from mapres import datamap
|
|
2
2
|
|
|
3
|
-
@datamap
|
|
3
|
+
@datamap.braces.config(recursive=True)
|
|
4
4
|
class MessagesConfig:
|
|
5
5
|
__user_config_path__ = 'config/messages.yaml'
|
|
6
6
|
__default_config_path__ = 'defaultconfigs/messages.yaml'
|
|
@@ -14,7 +14,12 @@ server:
|
|
|
14
14
|
|
|
15
15
|
hungerbridge:
|
|
16
16
|
token: 'CHANGE_ME'
|
|
17
|
-
url: 'https://api.example.com
|
|
17
|
+
url: 'https://api.example.com'
|
|
18
|
+
|
|
19
|
+
discord:
|
|
20
|
+
enabled: False
|
|
21
|
+
token: 'CHANGE_ME'
|
|
22
|
+
url: 'https://bot.example.com/webhook'
|
|
18
23
|
|
|
19
24
|
logger:
|
|
20
25
|
enabled: True
|
|
@@ -9,22 +9,22 @@
|
|
|
9
9
|
# <red> <green> <yellow> <reset>
|
|
10
10
|
#
|
|
11
11
|
# 2. GlobalConfig (config)
|
|
12
|
-
# Provides server-wide configuration values. Syntax: {field}
|
|
12
|
+
# Provides server-wide configuration values. Syntax: {{field}}
|
|
13
13
|
# Examples:
|
|
14
|
-
# {server_name}
|
|
15
|
-
# {panel_url}
|
|
14
|
+
# {{server_name}}
|
|
15
|
+
# {{panel_url}}
|
|
16
16
|
#
|
|
17
17
|
# 3. MessagesConfig (keys)
|
|
18
|
-
# Provides message templates. Syntax: {field}
|
|
18
|
+
# Provides message templates. Syntax: {{field}}
|
|
19
19
|
# Examples:
|
|
20
|
-
# {prefix}
|
|
21
|
-
# {broadcast_restart_at}
|
|
20
|
+
# {{prefix}}
|
|
21
|
+
# {{broadcast_restart_at}}
|
|
22
22
|
#
|
|
23
23
|
# 4. WatcherConfig (config)
|
|
24
|
-
# Provides thresholds, weights, and timing values. Syntax: {field}
|
|
24
|
+
# Provides thresholds, weights, and timing values. Syntax: {{field}}
|
|
25
25
|
# Examples:
|
|
26
|
-
# {threshold_ram}
|
|
27
|
-
# {low_gap_minutes}
|
|
26
|
+
# {{threshold_ram}}
|
|
27
|
+
# {{low_gap_minutes}}
|
|
28
28
|
#
|
|
29
29
|
# 5. TimeMap (dynamic)
|
|
30
30
|
# Provides live timestamps. Syntax: %field%
|
|
@@ -41,11 +41,11 @@
|
|
|
41
41
|
prefix: '<aqua>[Server Watcher]'
|
|
42
42
|
bullet: '-'
|
|
43
43
|
|
|
44
|
-
broadcast_restart_at: '{prefix} The server will restart at {time} CDT.'
|
|
44
|
+
broadcast_restart_at: '{{prefix}} The server will restart at {{time}} CDT.'
|
|
45
45
|
|
|
46
46
|
broadcast_templates:
|
|
47
|
-
minutes: '{prefix} Restart in {n} minute{s}!'
|
|
48
|
-
seconds: '{prefix} <red>Restarting in {n} second{s}!'
|
|
47
|
+
minutes: '{{prefix}} Restart in {{n}} minute{{s}}!'
|
|
48
|
+
seconds: '{{prefix}} <red>Restarting in {{n}} second{{s}}!'
|
|
49
49
|
|
|
50
50
|
broadcast_minutes: {}
|
|
51
51
|
broadcast_seconds: {}
|
|
@@ -55,25 +55,25 @@ logging:
|
|
|
55
55
|
status_check: 'Checking server status...'
|
|
56
56
|
validation_fail: 'Validation FAILED.'
|
|
57
57
|
validation_ok: 'All validation checks succeeded.'
|
|
58
|
-
sampling_start: 'Starting sampling process. This should take about {duration} seconds...'
|
|
58
|
+
sampling_start: 'Starting sampling process. This should take about {{duration}} seconds...'
|
|
59
59
|
shutdown: 'Shutting down ServerWatcher.'
|
|
60
60
|
immediate_restart: 'Restarting immediately.'
|
|
61
61
|
no_restart: 'The server does not need to restart.'
|
|
62
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.'
|
|
63
|
+
gap_low: 'Gap {{gap}}. Scheduling restart in 2 hours.'
|
|
64
|
+
gap_high: 'Gap {{gap}}. Scheduling restart in 1 hour.'
|
|
65
65
|
|
|
66
66
|
reasons:
|
|
67
67
|
pro_splash: 'PRO-RESTART REASONS:'
|
|
68
68
|
anti_splash: 'ANTI-RESTART REASONS:'
|
|
69
69
|
|
|
70
70
|
restart_soon: 'The server is set to restart soon'
|
|
71
|
-
ram: 'RAM usage ({ram}) is higher than {threshold} GB'
|
|
72
|
-
cpu: 'CPU usage ({cpu}) is higher than {threshold}%'
|
|
73
|
-
uptime: 'Uptime {uptime} exceeds {threshold}h'
|
|
74
|
-
tps: 'TPS {tps} is lower than {threshold}'
|
|
75
|
-
low_uptime: 'Uptime {uptime} is shorter than 30m'
|
|
76
|
-
players: 'There {verb} {count} {plural} online' # produces: 'There are 2 players online' or 'There is 1 player online'
|
|
71
|
+
ram: 'RAM usage ({{ram}}) is higher than {{threshold}} GB'
|
|
72
|
+
cpu: 'CPU usage ({{cpu}}) is higher than {{threshold}}%'
|
|
73
|
+
uptime: 'Uptime {{uptime}} exceeds {{threshold}}h'
|
|
74
|
+
tps: 'TPS {{tps}} is lower than {{threshold}}'
|
|
75
|
+
low_uptime: 'Uptime {{uptime}} is shorter than 30m'
|
|
76
|
+
players: 'There {{verb}} {{count}} {{plural}} online' # produces: 'There are 2 players online' or 'There is 1 player online'
|
|
77
77
|
|
|
78
78
|
pro_restart_number: 'Pro-restart: '
|
|
79
79
|
anti_restart_number: 'Anti-restart:'
|
serverwatcher/validator.py
CHANGED
|
@@ -18,6 +18,20 @@ def validate_global_config(c):
|
|
|
18
18
|
if not f.name.startswith('__'):
|
|
19
19
|
v.check_field(c, f.name)
|
|
20
20
|
|
|
21
|
+
# --- URL validation ---
|
|
22
|
+
if c.discord_enabled:
|
|
23
|
+
url = c.discord_url.strip()
|
|
24
|
+
|
|
25
|
+
if not url.startswith('https://'):
|
|
26
|
+
v.errors.append(f'discord_url: must start with https:// (got "{url}")')
|
|
27
|
+
|
|
28
|
+
# optional: detect example.com placeholder
|
|
29
|
+
if 'example.com' in url:
|
|
30
|
+
v.errors.append(f'discord_url: placeholder URL detected ("{url}")')
|
|
31
|
+
|
|
32
|
+
if c.discord_token == 'CHANGE_ME':
|
|
33
|
+
v.errors.append('discord_token: must be configured (got "CHANGE_ME")')
|
|
34
|
+
|
|
21
35
|
|
|
22
36
|
def validate_watcher_config(c):
|
|
23
37
|
for f in fields(WatcherConfig):
|
serverwatcher/watcher.py
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import os
|
|
2
1
|
import time
|
|
2
|
+
import traceback
|
|
3
3
|
from zoneinfo import ZoneInfo
|
|
4
4
|
|
|
5
|
-
from hungerlib import servers, MessageRouter, loadConfig, utils
|
|
5
|
+
from hungerlib import servers, MessageRouter, loadConfig, WebhookClient, utils
|
|
6
|
+
from hungerlib.configloader import deep_get
|
|
6
7
|
from mapres import MapResolver, maps
|
|
7
8
|
|
|
8
9
|
from serverwatcher.configclasses.config import GlobalConfig
|
|
@@ -89,6 +90,9 @@ class ServerWatcher:
|
|
|
89
90
|
info_prefix=self.config.info_prefix,
|
|
90
91
|
warn_prefix=self.config.warn_prefix,
|
|
91
92
|
error_prefix=self.config.error_prefix,
|
|
93
|
+
|
|
94
|
+
buffer_enabled=True,
|
|
95
|
+
origin_output=True
|
|
92
96
|
)
|
|
93
97
|
|
|
94
98
|
self.router.registerLevel(
|
|
@@ -100,9 +104,23 @@ class ServerWatcher:
|
|
|
100
104
|
|
|
101
105
|
self.tz = ZoneInfo(self.config.timezone)
|
|
102
106
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
107
|
+
self.Webhook = WebhookClient(
|
|
108
|
+
url=self.config.discord_url,
|
|
109
|
+
token=self.config.discord_token
|
|
110
|
+
)
|
|
111
|
+
|
|
112
|
+
def webhookSend(self, event: str, **ctx):
|
|
113
|
+
if self.config.discord_enabled:
|
|
114
|
+
self.Webhook.send(event=event, **ctx)
|
|
115
|
+
|
|
116
|
+
def clearTerminal(self, conditional=True):
|
|
117
|
+
self.router.buffer.clear()
|
|
118
|
+
if conditional:
|
|
119
|
+
if self.config.clear_terminal and not self.router.buffer.enabled: # if clearing terminal is enabled and buffer is disabled
|
|
120
|
+
utils.clearTerminal()
|
|
121
|
+
else:
|
|
122
|
+
if not self.router.buffer.enabled: # if buffer disabled
|
|
123
|
+
utils.clearTerminal()
|
|
106
124
|
|
|
107
125
|
def shutdown(self):
|
|
108
126
|
self.router.info(self.messages.shutdown)
|
|
@@ -110,7 +128,10 @@ class ServerWatcher:
|
|
|
110
128
|
|
|
111
129
|
def restart_and_wait(self):
|
|
112
130
|
self.server.restart()
|
|
131
|
+
|
|
113
132
|
self.router.info(self.messages.restart_action_sent)
|
|
133
|
+
self.webhookSend(event='restart_action_sent', server=self.config.server_name)
|
|
134
|
+
|
|
114
135
|
time.sleep(self.watcherconfig.restart_wait_seconds)
|
|
115
136
|
|
|
116
137
|
self.router.warn(self.messages.status_check)
|
|
@@ -123,8 +144,10 @@ class ServerWatcher:
|
|
|
123
144
|
if alive:
|
|
124
145
|
self.router.info(self.messages.server_back_online)
|
|
125
146
|
self.router.destination(self.messages.server_back_online_log)
|
|
147
|
+
self.webhookSend(event='server_back_online', server=self.config.server_name)
|
|
126
148
|
else:
|
|
127
149
|
self.router.error(self.messages.server_failed_restart)
|
|
150
|
+
self.webhookSend(event='server_failed_restart', server=self.config.server_name)
|
|
128
151
|
|
|
129
152
|
def schedule_restart(self, minutes):
|
|
130
153
|
info = utils.snapSchedule(
|
|
@@ -137,6 +160,7 @@ class ServerWatcher:
|
|
|
137
160
|
time_str = local_time.strftime('%I:%M %p')
|
|
138
161
|
|
|
139
162
|
self.router.broadcast(self.messages.broadcast_restart_at, time=time_str)
|
|
163
|
+
self.webhookSend(event='restart_scheduled', server=self.config.server_name, time=time_str)
|
|
140
164
|
|
|
141
165
|
def plural(n):
|
|
142
166
|
return '' if n == 1 else 's'
|
|
@@ -176,8 +200,10 @@ class ServerWatcher:
|
|
|
176
200
|
)
|
|
177
201
|
|
|
178
202
|
def evaluate(self):
|
|
203
|
+
self.router.buffer.disable()
|
|
179
204
|
self.router.info('ServerWatcher is running!')
|
|
180
|
-
|
|
205
|
+
self.clearTerminal(conditional=False)
|
|
206
|
+
self.router.buffer.enable()
|
|
181
207
|
|
|
182
208
|
self.router.info(self.messages.startup)
|
|
183
209
|
|
|
@@ -185,9 +211,10 @@ class ServerWatcher:
|
|
|
185
211
|
for i in range(5):
|
|
186
212
|
if utils.validateAll(self.panel, self.server):
|
|
187
213
|
break
|
|
188
|
-
time.sleep(
|
|
214
|
+
time.sleep(5)
|
|
189
215
|
else:
|
|
190
216
|
self.router.error(self.messages.validation_fail)
|
|
217
|
+
self.webhookSend(event='validation_fail', server=self.config.server_name)
|
|
191
218
|
return
|
|
192
219
|
|
|
193
220
|
sample_duration_formatted = int(self.watcherconfig.sample_duration) if self.watcherconfig.sample_duration.is_integer() else self.watcherconfig.sample_duration
|
|
@@ -200,6 +227,13 @@ class ServerWatcher:
|
|
|
200
227
|
restart_reasons = []
|
|
201
228
|
no_restart_reasons = []
|
|
202
229
|
|
|
230
|
+
# NoneType error handling (for slower panels and apis)
|
|
231
|
+
resourcelist = [snap.ram, snap.cpu, snap.uptime, snap.tps, snap.players]
|
|
232
|
+
if any(item is None for item in resourcelist):
|
|
233
|
+
self.router.error(self.messages.sampling_fail)
|
|
234
|
+
self.webhookSend(event='sampling_fail', server=self.config.server_name)
|
|
235
|
+
return
|
|
236
|
+
|
|
203
237
|
if self.config.debug:
|
|
204
238
|
self.router.debug(f'RAM: {snap.ram}/{self.watcherconfig.threshold_ram}')
|
|
205
239
|
self.router.debug(f'CPU: {snap.cpu}/{self.watcherconfig.threshold_cpu}')
|
|
@@ -246,11 +280,10 @@ class ServerWatcher:
|
|
|
246
280
|
self.router.warn(f'{self.messages.pro_restart_number} {pro}')
|
|
247
281
|
self.router.warn(f'{self.messages.anti_restart_number} {anti}')
|
|
248
282
|
|
|
249
|
-
gap =
|
|
283
|
+
gap = pro - anti
|
|
250
284
|
|
|
251
285
|
if pro == 0:
|
|
252
286
|
self.router.info(self.messages.no_restart)
|
|
253
|
-
# will add something here later
|
|
254
287
|
return
|
|
255
288
|
|
|
256
289
|
if pro > anti and snap.players == 0:
|
|
@@ -270,20 +303,62 @@ class ServerWatcher:
|
|
|
270
303
|
self.restart_and_wait()
|
|
271
304
|
|
|
272
305
|
def run(self):
|
|
273
|
-
|
|
306
|
+
crash_times = [] # timestamps of recent crashes
|
|
307
|
+
|
|
308
|
+
while True:
|
|
274
309
|
try:
|
|
275
|
-
|
|
276
|
-
utils.clearTerminal()
|
|
277
|
-
self.evaluate()
|
|
278
|
-
if self.config.debug:
|
|
279
|
-
self.router.debug(f'Waiting {self.watcherconfig.watch_interval}s until next run...')
|
|
280
|
-
time.sleep(self.watcherconfig.watch_interval)
|
|
281
|
-
except KeyboardInterrupt:
|
|
282
|
-
self.shutdown()
|
|
283
|
-
else:
|
|
284
|
-
while True:
|
|
285
|
-
utils.clearTerminal()
|
|
310
|
+
self.clearTerminal()
|
|
286
311
|
self.evaluate()
|
|
312
|
+
|
|
287
313
|
if self.config.debug:
|
|
288
314
|
self.router.debug(f'Waiting {self.watcherconfig.watch_interval}s until next run...')
|
|
315
|
+
|
|
289
316
|
time.sleep(self.watcherconfig.watch_interval)
|
|
317
|
+
|
|
318
|
+
except KeyboardInterrupt:
|
|
319
|
+
if self.config.handle_keyboard_interrupt:
|
|
320
|
+
self.shutdown()
|
|
321
|
+
else:
|
|
322
|
+
raise
|
|
323
|
+
|
|
324
|
+
except Exception as e:
|
|
325
|
+
now = time.time()
|
|
326
|
+
crash_times.append(now)
|
|
327
|
+
|
|
328
|
+
# keep only crashes in last 60 seconds
|
|
329
|
+
crash_times = [t for t in crash_times if now - t <= 60]
|
|
330
|
+
|
|
331
|
+
# format traceback
|
|
332
|
+
tb = ''.join(traceback.format_exception(type(e), e, e.__traceback__))
|
|
333
|
+
|
|
334
|
+
# log locally
|
|
335
|
+
try:
|
|
336
|
+
with open('watcher_errors.log', 'a') as f:
|
|
337
|
+
f.write('\n\n=== Unexpected Error ===\n')
|
|
338
|
+
f.write(tb)
|
|
339
|
+
except Exception:
|
|
340
|
+
pass
|
|
341
|
+
|
|
342
|
+
# router log
|
|
343
|
+
self.router.error('Unexpected error in watcher loop:')
|
|
344
|
+
self.router.error(tb)
|
|
345
|
+
|
|
346
|
+
# webhook spam protection
|
|
347
|
+
if len(crash_times) <= 3:
|
|
348
|
+
try:
|
|
349
|
+
self.webhookSend(
|
|
350
|
+
event='unexpected_error',
|
|
351
|
+
server=self.config.server_name,
|
|
352
|
+
error=tb[:1800]
|
|
353
|
+
)
|
|
354
|
+
except Exception:
|
|
355
|
+
self.router.warn('Failed to send Discord webhook for unexpected error.')
|
|
356
|
+
else:
|
|
357
|
+
self.router.warn('Error rate high — suppressing webhook spam.')
|
|
358
|
+
|
|
359
|
+
# exponential backoff
|
|
360
|
+
backoff = min(2 ** len(crash_times), self.watcherconfig.watch_interval)
|
|
361
|
+
self.router.warn(f'Backing off for {backoff}s due to repeated errors.')
|
|
362
|
+
time.sleep(backoff)
|
|
363
|
+
|
|
364
|
+
continue
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: serverwatcher
|
|
3
|
+
Version: 6.dev2
|
|
4
|
+
Summary: A HungerLib-powered Minecraft server automation engine.
|
|
5
|
+
Author: iFamished
|
|
6
|
+
License: GPL-3.0
|
|
7
|
+
Project-URL: Homepage, https://github.com/iFamishedX/ServerWatcher
|
|
8
|
+
Project-URL: Documentation, https://github.com/iFamishedX/ServerWatcher
|
|
9
|
+
Project-URL: Source, https://github.com/iFamishedX/ServerWatcher
|
|
10
|
+
Project-URL: Issues, https://github.com/iFamishedX/ServerWatcher/issues
|
|
11
|
+
Keywords: pterodactyl,minecraft,automation,rcon,server-management,hungerlib,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: requests
|
|
26
|
+
Requires-Dist: mcrcon
|
|
27
|
+
Requires-Dist: hungerlib>=3.1
|
|
28
|
+
Requires-Dist: PyYaml
|
|
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
|
+
*Discord bot*
|
|
51
|
+
- Optional. The bot must have the correct endpoints set up.
|
|
52
|
+
*Logging directory*
|
|
53
|
+
- Optional. Only necessary if you want to use file logging.
|
|
54
|
+
|
|
55
|
+
## Installation
|
|
56
|
+
- Download the [**ServerWatcher Pterodactyl egg**](https://github.com/iFamishedX/ServerWatcher/blob/main/eggs/serverwatcher.json)
|
|
57
|
+
- Import it into your desired nest in your panel
|
|
58
|
+
- Create a server with the egg selected
|
|
59
|
+
- Start the server and wait for instalation and file generation to finish
|
|
60
|
+
- Configure the files in config/
|
|
61
|
+
- Start the server again
|
|
62
|
+
- You're done! Just let it do its thing.
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
serverwatcher/__init__.py,sha256=Q_afN0XU29n48d6Gf0-LT2lLo3RiTWlHRT6rC_fYbjw,486
|
|
2
|
+
serverwatcher/__main__.py,sha256=XjGcQ_-8p4ttuVYlYEvYKUEvcAsvZUQaEA0mX0ajRbU,3097
|
|
3
|
+
serverwatcher/cli.py,sha256=scVUrEHn4MUTz0W3AADeU5bDuSsNtLbs1vim-yw8R4s,10551
|
|
4
|
+
serverwatcher/validator.py,sha256=aD6GHOz1S5VFC93Mj89WO9vZG1bTjhg7QZbdlvQf4wo,1778
|
|
5
|
+
serverwatcher/watcher.py,sha256=ZiocJpeyhKTGOwYYak36MXNEFpLnpdl9v6BnMPGrBmM,13593
|
|
6
|
+
serverwatcher/configclasses/__init__.py,sha256=YS0KhxtAJGdMcaiFstqTRNxIPLnR7s9v3Tkt5h2uKE4,182
|
|
7
|
+
serverwatcher/configclasses/config.py,sha256=1Upor55QFE4UIOqL9ZYa4U5kbda48GG9HWdRXg8mb_Y,2418
|
|
8
|
+
serverwatcher/configclasses/messages.py,sha256=iOkCvwagngW4aeWD5I6hi6cqqDkzEsFJsLHSuqK-P1s,3467
|
|
9
|
+
serverwatcher/configclasses/watcher.py,sha256=OIAYQZF9hD9e5FbcaYV5N9CAdCZoLgXSqAMh_MOayaw,2727
|
|
10
|
+
serverwatcher/defaultconfigs/config.yaml,sha256=yrJ59Jx0F4TJzE1EdBF5IKPCDqs09XcbKHFfkYGJ1ys,721
|
|
11
|
+
serverwatcher/defaultconfigs/messages.yaml,sha256=jSVEl-RYqPHhe5U5KLl8zfJtUBymvyE74hmzH0RFC_Y,3177
|
|
12
|
+
serverwatcher/defaultconfigs/watcher.yaml,sha256=GlAEKCuzFUSF6wWOqQLFL1CeuPltb1ltfYxFe_FUClw,723
|
|
13
|
+
serverwatcher-6.dev2.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
|
|
14
|
+
serverwatcher-6.dev2.dist-info/METADATA,sha256=TDUf2JgkW6vWztOTK0cuEaP2NAX946IPp34tAGXymvs,2646
|
|
15
|
+
serverwatcher-6.dev2.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
|
|
16
|
+
serverwatcher-6.dev2.dist-info/top_level.txt,sha256=8DJAf8WmmglgtZHkp8aoTriRJ2YPcS4F3DfOIkytASo,14
|
|
17
|
+
serverwatcher-6.dev2.dist-info/RECORD,,
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: serverwatcher
|
|
3
|
-
Version: 5.33.dev4
|
|
4
|
-
Summary: A HungerLib-powered Minecraft server automation engine.
|
|
5
|
-
Author: iFamished
|
|
6
|
-
License: GPL-3.0
|
|
7
|
-
Project-URL: Homepage, https://github.com/iFamishedX/ServerWatcher
|
|
8
|
-
Project-URL: Documentation, https://github.com/iFamishedX/ServerWatcher
|
|
9
|
-
Project-URL: Source, https://github.com/iFamishedX/ServerWatcher
|
|
10
|
-
Project-URL: Issues, https://github.com/iFamishedX/ServerWatcher/issues
|
|
11
|
-
Keywords: pterodactyl,minecraft,automation,rcon,server-management,hungerlib,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: requests
|
|
26
|
-
Requires-Dist: mcrcon
|
|
27
|
-
Requires-Dist: hungerlib>=3.1
|
|
28
|
-
Requires-Dist: PyYaml
|
|
29
|
-
Requires-Dist: mapres
|
|
30
|
-
Dynamic: license-file
|
|
31
|
-
|
|
32
|
-
# ServerWatcher
|
|
33
|
-
|
|
34
|
-
A configurable server monitoring and restart engine for HungerLib / Pterodactyl-based Minecraft servers.
|
|
35
|
-
|
|
36
|
-
## Usage
|
|
37
|
-
```bash
|
|
38
|
-
pip install serverwatcher
|
|
39
|
-
```
|
|
40
|
-
```python
|
|
41
|
-
from serverwatcher.watcher import ServerWatcher
|
|
42
|
-
from serverwatcher.config import WatcherConfig
|
|
43
|
-
from serverwatcher.messages import WatcherMessages
|
|
44
|
-
|
|
45
|
-
watcher = ServerWatcher(server, origin, panel, logger, WatcherConfig(), WatcherMessages())
|
|
46
|
-
watcher.evaluate()
|
|
47
|
-
```
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
serverwatcher/__init__.py,sha256=Q_afN0XU29n48d6Gf0-LT2lLo3RiTWlHRT6rC_fYbjw,486
|
|
2
|
-
serverwatcher/__main__.py,sha256=XBz1dYfQSN5FRah7xfQaJ82b-dc0qoscVHYs5Snma_c,991
|
|
3
|
-
serverwatcher/validator.py,sha256=fgItW9NPYxFPseQIK_d_iNBdxwST2Gw8i4wOlBKls98,1258
|
|
4
|
-
serverwatcher/watcher.py,sha256=vW6YdT4srtQetqeLFEPuehUgOi4wzDLwhbL2ggimTjg,10628
|
|
5
|
-
serverwatcher/configclasses/__init__.py,sha256=YS0KhxtAJGdMcaiFstqTRNxIPLnR7s9v3Tkt5h2uKE4,182
|
|
6
|
-
serverwatcher/configclasses/config.py,sha256=2iQslC6z8_c7UBDe8EzbtFI_-w5tQRKlOuWyARWPyLw,2134
|
|
7
|
-
serverwatcher/configclasses/messages.py,sha256=8SqAhHrnByz0IxCfkbp2_Bd5ha9yUzKfNwD_R1SEYbs,3482
|
|
8
|
-
serverwatcher/configclasses/watcher.py,sha256=wBBAP3nQJ4FTqRxafIr1JRUEtzqAWUBLx1nVT8FGur4,2720
|
|
9
|
-
serverwatcher/defaultconfigs/config.yaml,sha256=tNywPeyqYh9xGpSkxdeYv_T9EBuyvSJKaQhmOSnNFy0,637
|
|
10
|
-
serverwatcher/defaultconfigs/messages.yaml,sha256=IX27K9qSIsGQkyL9aULRP_zq1xMwTQSNtO-Xoxg0IrU,3113
|
|
11
|
-
serverwatcher/defaultconfigs/watcher.yaml,sha256=GlAEKCuzFUSF6wWOqQLFL1CeuPltb1ltfYxFe_FUClw,723
|
|
12
|
-
serverwatcher-5.33.dev4.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
|
|
13
|
-
serverwatcher-5.33.dev4.dist-info/METADATA,sha256=E2h_6OscB5yM6oW5iO2dbzb-Bg24zwa9adMP2CpyvRQ,1714
|
|
14
|
-
serverwatcher-5.33.dev4.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
|
|
15
|
-
serverwatcher-5.33.dev4.dist-info/top_level.txt,sha256=8DJAf8WmmglgtZHkp8aoTriRJ2YPcS4F3DfOIkytASo,14
|
|
16
|
-
serverwatcher-5.33.dev4.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|