Install authenticated native web proxy with user autostart
Register the existing native supervisor with launchd/systemd, include the dependency-free authenticated web proxy, detect Node, and keep the API loopback by default. Preserve existing web credentials and configured host harness defaults. Clarify single-step setup, lifecycle selection, and optional ntfy limits. Checks: 44 mocked native installer/lifecycle tests; 8 entrypoint tests; 42 Docker installer tests; GOPROXY=off GOTOOLCHAIN=local go test ./internal/installation ./cmd/pipelines; sh -n install install.sh; git diff --check. No live install, deployment, restart, downloads, real autostart/login verification or native Linux verification.
This commit is contained in:
+38
-3
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env python3
|
||||
"""One per-user lifecycle for the native server and its private Docker ntfy."""
|
||||
"""One per-user lifecycle for the server, authenticated web proxy and ntfy."""
|
||||
import argparse
|
||||
import fcntl
|
||||
import json
|
||||
@@ -110,6 +110,7 @@ def start(config):
|
||||
if registration(config):
|
||||
if platform.system() == "Darwin":
|
||||
target = f"gui/{os.getuid()}/{config['label']}"
|
||||
run(["launchctl", "enable", target], quiet=True)
|
||||
if run(["launchctl", "print", target], quiet=True, check=False).returncode:
|
||||
run(["launchctl", "bootstrap", f"gui/{os.getuid()}", registration(config)], quiet=True)
|
||||
run(["launchctl", "kickstart", target], quiet=True)
|
||||
@@ -122,6 +123,20 @@ def start(config):
|
||||
stdin=subprocess.DEVNULL, stdout=log, stderr=log, start_new_session=True)
|
||||
log.close()
|
||||
wait_health(f"http://127.0.0.1:{config['server_port']}/healthz", timeout=75)
|
||||
if config.get("web"):
|
||||
web = config["web"]
|
||||
host = "127.0.0.1" if web["host"] == "0.0.0.0" else web["host"]
|
||||
end = time.monotonic() + 20
|
||||
while True:
|
||||
try:
|
||||
with urllib.request.urlopen(f"http://{host}:{web['port']}/login", timeout=2) as response:
|
||||
if response.status == 200:
|
||||
break
|
||||
except OSError:
|
||||
pass
|
||||
if time.monotonic() >= end:
|
||||
raise RuntimeError("Web proxy did not become ready; see logs/web.log")
|
||||
time.sleep(0.25)
|
||||
|
||||
|
||||
def stop(config):
|
||||
@@ -194,11 +209,12 @@ def supervise(config):
|
||||
stopped = False
|
||||
child = None
|
||||
ntfy_child = None
|
||||
web_child = None
|
||||
|
||||
def stopping(*_):
|
||||
nonlocal stopped
|
||||
stopped = True
|
||||
for process in (child, ntfy_child):
|
||||
for process in (child, ntfy_child, web_child):
|
||||
if process is not None and process.poll() is None:
|
||||
process.terminate()
|
||||
|
||||
@@ -222,12 +238,31 @@ def supervise(config):
|
||||
with (root / "logs/server.log").open("a") as log:
|
||||
child = subprocess.Popen([str(root / "bin/pipelines-server"), "-addr",
|
||||
server_address(config), "-db", str(root / "data/pipelines.db")],
|
||||
cwd=config["workspace"], env=env, stdout=log, stderr=log)
|
||||
cwd=config["workspace"], env=env, stdout=log, stderr=log)
|
||||
if config.get("web"):
|
||||
web = config["web"]
|
||||
web_env = dict(env)
|
||||
web_env.pop("PIPELINES_WEB_AUTH", None)
|
||||
web_env["PIPELINES_WEB_AUTH_FILE"] = web["auth_file"]
|
||||
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']}"],
|
||||
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:
|
||||
raise RuntimeError("Authenticated web proxy exited; see logs/web.log")
|
||||
time.sleep(0.25)
|
||||
if not stopped and child.returncode:
|
||||
raise RuntimeError("Pipeline server exited; see logs/server.log")
|
||||
finally:
|
||||
if web_child is not None and web_child.poll() is None:
|
||||
web_child.terminate()
|
||||
try:
|
||||
web_child.wait(timeout=10)
|
||||
except subprocess.TimeoutExpired:
|
||||
web_child.kill()
|
||||
web_child.wait()
|
||||
if child is not None and child.poll() is None:
|
||||
child.terminate()
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user