Files
pipelines/internal/statusview/status.go
T
alan 32029cf58f Merge main: ntfy removed, first-run messages kept
Resolved docs/install.md, internal/cli/app.go, internal/statusview and
scripts/setup-native.py: no ntfy anywhere (connection, status, installer
constants, troubleshooting ports), keeping the first-run next steps, the
unreachable-server and tool/Docker install hints. README drops the C
compiler (ntfy was its only user). The installer summary's password
wording is now per run (a reinstall in the same process no longer says
"you just chose"), and its test checks the URLs then the next steps.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-03 23:54:57 +00:00

50 lines
1.4 KiB
Go

package statusview
import (
"git.a-wan.net/alan/pipelines/internal/protocol"
"net"
"net/url"
"strings"
)
func Offline(endpoint string) *protocol.SystemStatus {
s := &protocol.SystemStatus{Server: protocol.ServiceStatus{Health: "unreachable"}}
if u, err := url.Parse(endpoint); err == nil {
s.Server.Port = u.Port()
}
return s
}
func ServerLines(s *protocol.SystemStatus) []string {
if s == nil {
return []string{"Checking server…"}
}
lines := []string{"Status: " + s.Server.Health}
seen := map[string]bool{}
for _, address := range s.Addresses {
ip := net.ParseIP(strings.Split(address.IP, "%")[0])
if ip == nil || ip.IsLoopback() || ip.IsUnspecified() || ip.IsLinkLocalUnicast() || seen[address.IP] {
continue
}
seen[address.IP] = true
lines = append(lines, net.JoinHostPort(address.IP, s.Server.Port))
if len(seen) == 6 {
break
}
}
if s.Server.Health == "unreachable" {
lines = append(lines, "Is it running? Start it with `pipelines start` (installed service) or `pipelines serve`.")
} else if len(seen) == 0 {
lines = append(lines, "LAN address unavailable.", "For a Docker install: rerun ./install --docker on the server.")
}
if s.Server.Port != "" {
lines = append(lines, "Port: "+s.Server.Port)
}
return lines
}
// The human view is one focused section. --json retains full data.
func Lines(s *protocol.SystemStatus) []string {
return append([]string{"Pipelines server"}, ServerLines(s)...)
}