feat(install): build the Flutter web app in Docker, optional ./install --apk, chosen web password, startup report
This commit is contained in:
+47
-1
@@ -268,6 +268,47 @@ def ntfy_stop(config):
|
||||
path.unlink(missing_ok=True)
|
||||
|
||||
|
||||
def server_report(config):
|
||||
"""The server's own startup report: the last `== Pipelines server` block
|
||||
it wrote to its log."""
|
||||
log = Path(config["prefix"]) / "logs/server.log"
|
||||
try:
|
||||
with log.open("rb") as handle:
|
||||
handle.seek(max(0, log.stat().st_size - 64 * 1024))
|
||||
lines = handle.read().decode("utf-8", "replace").splitlines()
|
||||
except OSError:
|
||||
return []
|
||||
starts = [i for i, line in enumerate(lines) if line.startswith("== Pipelines server")]
|
||||
if not starts:
|
||||
return []
|
||||
block = []
|
||||
for line in lines[starts[-1]:]:
|
||||
block.append(line)
|
||||
if line == "==":
|
||||
break
|
||||
return block
|
||||
|
||||
|
||||
def report(config):
|
||||
"""Prints what is running: server, backends, web app and phone access."""
|
||||
for line in server_report(config):
|
||||
print(line)
|
||||
web = config.get("web")
|
||||
if web:
|
||||
public = (config.get("opencode_env") or {}).get("PIPELINES_WEB_PUBLIC_URL")
|
||||
print("== Access")
|
||||
address = public or f"http://{web['host']}:{web['port']}"
|
||||
print(f" {'Web':<10} {address} (password in {web['auth_file']})")
|
||||
root = Path(web["root"]) if web.get("root") else None
|
||||
built = root is not None and (root / "index.html").is_file()
|
||||
print(f" {'Web app':<10} {'installed' if built else 'not built; run ./install --web'}")
|
||||
updates = Path(web["updates"]) if web.get("updates") else None
|
||||
apk = updates is not None and (updates / "pipelines.apk").is_file()
|
||||
print(f" {'Phone app':<10} " + (f"{updates / 'pipelines.apk'} (Settings → Check for updates)"
|
||||
if apk else "not built; run ./install --apk"))
|
||||
print("==")
|
||||
|
||||
|
||||
def supervise(config):
|
||||
root = Path(config["prefix"])
|
||||
with (root / "supervisor.lock").open("a") as lock:
|
||||
@@ -320,7 +361,9 @@ def supervise(config):
|
||||
with (root / "logs/web.log").open("a") as web_log:
|
||||
web_child = subprocess.Popen(
|
||||
[web["node"], web["script"], "--port", str(web["port"]),
|
||||
"--host", web["host"], "--pipelines", f"127.0.0.1:{config['server_port']}"],
|
||||
"--host", web["host"], "--pipelines", f"127.0.0.1:{config['server_port']}",
|
||||
*(["--root", web["root"]] if web.get("root") else []),
|
||||
*(["--updates", web["updates"]] if web.get("updates") else [])],
|
||||
env=web_env, stdout=web_log, stderr=web_log)
|
||||
while child.poll() is None and not stopped:
|
||||
if web_child is not None and web_child.poll() is not None:
|
||||
@@ -419,11 +462,14 @@ def main():
|
||||
parser.error("unexpected arguments: " + " ".join(rest))
|
||||
if args.action == "start":
|
||||
start(config)
|
||||
report(config)
|
||||
elif args.action == "stop":
|
||||
stop(config)
|
||||
elif args.action == "restart":
|
||||
stop(config); start(config)
|
||||
report(config)
|
||||
elif args.action in ("status", "doctor"):
|
||||
report(config)
|
||||
print("Pipeline server:", "healthy" if healthy(f"http://127.0.0.1:{config['server_port']}/healthz") else "stopped/unhealthy")
|
||||
print("ntfy:", "healthy" if healthy(ntfy_health_url(config)) else "stopped/unhealthy")
|
||||
print("Phone server:", config["public_url"], "· topic:", config["topic"], "· username:", config["username"])
|
||||
|
||||
Reference in New Issue
Block a user