Spaces:
Paused
Paused
Add durability probe (boot counter + world presence) to status; detect the HF bucket mount
Browse files- control.py +16 -1
control.py
CHANGED
|
@@ -14,7 +14,7 @@ from collections import deque
|
|
| 14 |
from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer
|
| 15 |
from urllib.parse import parse_qs, urlparse
|
| 16 |
|
| 17 |
-
BUILD = "
|
| 18 |
|
| 19 |
DATA_DIR = os.environ.get("MC_DATA", "/data")
|
| 20 |
JAR = os.environ.get("MC_JAR", "/server/minecraft_server.26.3.jar")
|
|
@@ -223,7 +223,10 @@ class MCController:
|
|
| 223 |
proc_alive = proc is not None and proc.poll() is None
|
| 224 |
up = int(time.time() - self.started_at) if proc_alive and self.started_at else 0
|
| 225 |
rss = self._rss_kb(proc.pid) if proc_alive else 0
|
|
|
|
| 226 |
return {
|
|
|
|
|
|
|
| 227 |
"mc": "running" if proc_alive else "stopped",
|
| 228 |
"uptime": up,
|
| 229 |
"crashes": self.crashes,
|
|
@@ -643,6 +646,18 @@ $('cmd').addEventListener('keydown', e => { if (e.key === 'Enter') sendCmd(); })
|
|
| 643 |
|
| 644 |
|
| 645 |
def main():
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 646 |
controller.start_playit()
|
| 647 |
controller.start_java()
|
| 648 |
|
|
|
|
| 14 |
from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer
|
| 15 |
from urllib.parse import parse_qs, urlparse
|
| 16 |
|
| 17 |
+
BUILD = "v8"
|
| 18 |
|
| 19 |
DATA_DIR = os.environ.get("MC_DATA", "/data")
|
| 20 |
JAR = os.environ.get("MC_JAR", "/server/minecraft_server.26.3.jar")
|
|
|
|
| 223 |
proc_alive = proc is not None and proc.poll() is None
|
| 224 |
up = int(time.time() - self.started_at) if proc_alive and self.started_at else 0
|
| 225 |
rss = self._rss_kb(proc.pid) if proc_alive else 0
|
| 226 |
+
world = os.path.isdir(os.path.join(DATA_DIR, "world"))
|
| 227 |
return {
|
| 228 |
+
"world": "exists" if world else "none",
|
| 229 |
+
"probe": getattr(self, "boot_probe", 0),
|
| 230 |
"mc": "running" if proc_alive else "stopped",
|
| 231 |
"uptime": up,
|
| 232 |
"crashes": self.crashes,
|
|
|
|
| 646 |
|
| 647 |
|
| 648 |
def main():
|
| 649 |
+
probe_path = os.path.join(DATA_DIR, ".boot_probe")
|
| 650 |
+
try:
|
| 651 |
+
prev = int(open(probe_path).read()) if os.path.exists(probe_path) else 0
|
| 652 |
+
except ValueError:
|
| 653 |
+
prev = 0
|
| 654 |
+
controller.boot_probe = prev + 1
|
| 655 |
+
try:
|
| 656 |
+
with open(probe_path, "w") as f:
|
| 657 |
+
f.write(str(controller.boot_probe))
|
| 658 |
+
except OSError as e:
|
| 659 |
+
controller.push(f"[panel] cannot write to {DATA_DIR}: {e}")
|
| 660 |
+
|
| 661 |
controller.start_playit()
|
| 662 |
controller.start_java()
|
| 663 |
|