Serve one web app: route the tailnet address to the installed proxy
./install retires the pre-native standalone web agent (net.awan.pipelines.web, kept as .disabled) and, when the public web URL is a tailnet HTTPS address, points tailscale serve at the installed web proxy, failing the install if it cannot.
This commit is contained in:
@@ -405,6 +405,42 @@ class Setup:
|
||||
app_build.install_tree(built or self.build_app_web(), target)
|
||||
return str(target)
|
||||
|
||||
# --- one web app ---------------------------------------------------
|
||||
|
||||
# A standalone web proxy agent from before the native install. It served
|
||||
# a second copy of the web app, so the tailnet address showed an old build.
|
||||
LEGACY_WEB_LABEL = "net.awan.pipelines.web"
|
||||
|
||||
def retire_legacy_web(self):
|
||||
"""Stops the pre-native standalone web agent; its plist is kept as
|
||||
.disabled. The installed web proxy is the only web app."""
|
||||
if platform.system() != "Darwin":
|
||||
return
|
||||
plist = Path.home() / f"Library/LaunchAgents/{self.LEGACY_WEB_LABEL}.plist"
|
||||
if not plist.is_file():
|
||||
return
|
||||
self.runner(["launchctl", "bootout", f"gui/{os.getuid()}/{self.LEGACY_WEB_LABEL}"],
|
||||
capture_output=True, text=True)
|
||||
plist.rename(plist.with_name(plist.name + ".disabled"))
|
||||
print(f"Retired the old standalone web agent {self.LEGACY_WEB_LABEL} (kept as {plist.name}.disabled).")
|
||||
|
||||
def serve_on_tailnet(self, public_url, web_port):
|
||||
"""Points the tailnet HTTPS address recorded as the public web URL at
|
||||
the installed web proxy, so every address serves the same web app."""
|
||||
parsed = urlsplit(public_url)
|
||||
if parsed.scheme != "https" or not (parsed.hostname or "").endswith(".ts.net"):
|
||||
return
|
||||
tailscale = shutil.which("tailscale")
|
||||
if not tailscale:
|
||||
raise ValueError(f"The public web URL {public_url} is a tailnet address but tailscale is not on PATH")
|
||||
port = parsed.port or 443
|
||||
result = self.runner([tailscale, "serve", "--bg", f"--https={port}", f"http://127.0.0.1:{web_port}"],
|
||||
capture_output=True, text=True)
|
||||
if result.returncode:
|
||||
raise ValueError(f"tailscale serve could not point {public_url} at the web app: "
|
||||
+ ((result.stderr or "").strip().splitlines() or ["failed"])[-1])
|
||||
print(f"Tailnet: {public_url} serves the installed web app (port {web_port}).")
|
||||
|
||||
# --- build and skill -------------------------------------------------
|
||||
|
||||
COMMANDS = ("pipelines-server", "pipelines")
|
||||
@@ -874,6 +910,8 @@ class Setup:
|
||||
f"'PIPELINES_PREFIX={prefix} {prefix}/bin/pipelines start' to see the error. "
|
||||
"Check your login service manager and that ports "
|
||||
f"{args.port}, {args.ntfy_port} and {args.web_port} are free (a running Docker installation may use them).")
|
||||
self.retire_legacy_web()
|
||||
self.serve_on_tailnet(opencode_env["PIPELINES_WEB_PUBLIC_URL"], args.web_port)
|
||||
print(f"ntfy is configured for {base_url}; server, web proxy and ntfy have login autostart ({service_path}).")
|
||||
print("Phone notifications: subscribe to the 'pipelines' topic as phone-reader with the web password.")
|
||||
print(f"Web: http://{lan_ip if args.web_host == '0.0.0.0' else args.web_host}:{args.web_port}/ "
|
||||
|
||||
Reference in New Issue
Block a user