feat(statuspage): keep serving status pages while the api is down

Snapshots are persisted to UPTIME_STATUSPAGE_CACHE_DIR and loaded at
start, so pages survive restarts during an outage. Cached pages are
answered without waiting for the API, refreshed in the background and
served for as long as the API stays unreachable, with a notice once they
are older than five minutes. Only an explicit not found from the API
removes a page. Readiness no longer depends on the API when pages are
cached, the server starts without a reachable API, and certificates are
mirrored locally so HTTPS keeps working after a restart.

Closes #56

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
This commit is contained in:
Sebastian UnterschützandClaude Opus 5.5 committed 2026-11-22 09:05:20 +01:00
1 parent 20664dd5dd
commit 6e2f8d0626
12 files changed
+660 -214

No files matched your search

+46 -9
View File
@@ -11,6 +11,7 @@ import (
"net" "net"
"net/http" "net/http"
"os" "os"
"path/filepath"
"time" "time"
"github.com/caddyserver/certmagic" "github.com/caddyserver/certmagic"
@@ -49,31 +50,36 @@ func run(log *slog.Logger, level *slog.LevelVar) error {
defer stop() defer stop()
client := agentapi.NewClient(cfg.APIURL, cfg.Token, uuid.New(), buildinfo.Version) client := agentapi.NewClient(cfg.APIURL, cfg.Token, uuid.New(), buildinfo.Version)
hello, err := platform.Hello(ctx, client, log) if err := checkToken(ctx, client, log); err != nil {
if err != nil {
return err return err
} }
if hello.Kind != "statuspage" { cacheDir, err := resolveCacheDir(cfg.CacheDir)
return fmt.Errorf("token belongs to a %s agent, not a status page server", hello.Kind) if err != nil {
return err
} }
catalog, err := i18n.Load() catalog, err := i18n.Load()
if err != nil { if err != nil {
return err return err
} }
pages, err := statuspage.New(client, catalog, log, statuspage.Options{Hosts: cfg.Hosts, CacheDir: filepath.Join(cacheDir, "pages")})
if err != nil {
return err
}
apiProbe := func(ctx context.Context) error { _, err := client.Hello(ctx); return err }
health := platform.NewHealth(map[string]platform.Probe{ health := platform.NewHealth(map[string]platform.Probe{
"api": func(ctx context.Context) error { _, err := client.Hello(ctx); return err }, "pages": func(ctx context.Context) error { return pages.Ready(ctx, apiProbe) },
}) })
r := platform.NewRouter(log) r := platform.NewRouter(log)
health.Register(r) health.Register(r)
r.StaticFS("/static", web.Static()) r.StaticFS("/static", web.Static())
pages := statuspage.New(client, catalog, log, cfg.Hosts)
pages.Mount(r) pages.Mount(r)
go pages.Run(ctx)
if !cfg.TLS { if !cfg.TLS {
return platform.Serve(ctx, log, platform.NewHTTPServer(cfg.Listen, r), health, 5*time.Second, cfg.ShutdownTimeout) return platform.Serve(ctx, log, platform.NewHTTPServer(cfg.Listen, r), health, 5*time.Second, cfg.ShutdownTimeout)
} }
tlsConfig, challenges, err := certificates(ctx, cfg, client, pages, log) tlsConfig, challenges, err := certificates(ctx, cfg, client, pages, filepath.Join(cacheDir, "certs"), log)
if err != nil { if err != nil {
return err return err
} }
@@ -91,13 +97,13 @@ func run(log *slog.Logger, level *slog.LevelVar) error {
// certificates sets up on-demand ACME certificates stored through the API, // certificates sets up on-demand ACME certificates stored through the API,
// shared by every instance of this status page server. // shared by every instance of this status page server.
func certificates(ctx context.Context, cfg config.StatusPage, client *agentapi.Client, pages *statuspage.Server, log *slog.Logger) (*tls.Config, func(http.Handler) http.Handler, error) { func certificates(ctx context.Context, cfg config.StatusPage, client *agentapi.Client, pages *statuspage.Server, certDir string, log *slog.Logger) (*tls.Config, func(http.Handler) http.Handler, error) {
var magic *certmagic.Config var magic *certmagic.Config
cache := certmagic.NewCache(certmagic.CacheOptions{ cache := certmagic.NewCache(certmagic.CacheOptions{
GetConfigForCert: func(certmagic.Certificate) (*certmagic.Config, error) { return magic, nil }, GetConfigForCert: func(certmagic.Certificate) (*certmagic.Config, error) { return magic, nil },
}) })
magic = certmagic.New(cache, certmagic.Config{ magic = certmagic.New(cache, certmagic.Config{
Storage: statuspage.NewCertStorage(client), Storage: statuspage.NewCertStorage(client, certDir),
OnDemand: &certmagic.OnDemandConfig{DecisionFunc: pages.AllowCertificate}, OnDemand: &certmagic.OnDemandConfig{DecisionFunc: pages.AllowCertificate},
Logger: zap.NewNop(), Logger: zap.NewNop(),
}) })
@@ -128,3 +134,34 @@ func redirectToHTTPS(next http.Handler) http.Handler {
http.Redirect(w, r, "https://"+host+r.URL.RequestURI(), http.StatusMovedPermanently) http.Redirect(w, r, "https://"+host+r.URL.RequestURI(), http.StatusMovedPermanently)
}) })
} }
// checkToken rejects tokens of the wrong kind or revoked tokens, but starts
// anyway when the API is unreachable: cached pages must be served exactly
// when the rest of the system has trouble.
func checkToken(ctx context.Context, client *agentapi.Client, log *slog.Logger) error {
hctx, cancel := context.WithTimeout(ctx, 5*time.Second)
defer cancel()
hello, err := client.Hello(hctx)
switch {
case errors.Is(err, agentapi.ErrUnauthorized):
return err
case err != nil:
log.Warn("api unreachable at start; serving cached pages", "error", err)
return nil
case hello.Kind != "statuspage":
return fmt.Errorf("token belongs to a %s agent, not a status page server", hello.Kind)
}
log.Info("connected to api", "agent", hello.Name)
return nil
}
func resolveCacheDir(dir string) (string, error) {
if dir != "" {
return dir, nil
}
base, err := os.UserCacheDir()
if err != nil {
return "", fmt.Errorf("no cache directory; set UPTIME_STATUSPAGE_CACHE_DIR: %w", err)
}
return filepath.Join(base, "uptimesebi-statuspage"), nil
}
+4 -1
View File
@@ -104,7 +104,10 @@ func TestStatusPages(t *testing.T) {
t.Run("rendered by the status page server", func(t *testing.T) { t.Run("rendered by the status page server", func(t *testing.T) {
cat, _ := i18n.Load() cat, _ := i18n.Load()
srv := statuspage.New(platform, cat, slog.New(slog.DiscardHandler), []string{"status.test"}) srv, err := statuspage.New(platform, cat, slog.New(slog.DiscardHandler), statuspage.Options{Hosts: []string{"status.test"}})
if err != nil {
t.Fatal(err)
}
gin.SetMode(gin.TestMode) gin.SetMode(gin.TestMode)
router := gin.New() router := gin.New()
srv.Mount(router) srv.Mount(router)
+40 -3
View File
@@ -12,14 +12,18 @@ import (
"github.com/google/uuid" "github.com/google/uuid"
"git.zb-server.de/ZB-Server/uptimesebi/internal/agentapi"
"git.zb-server.de/ZB-Server/uptimesebi/internal/api"
"git.zb-server.de/ZB-Server/uptimesebi/internal/i18n" "git.zb-server.de/ZB-Server/uptimesebi/internal/i18n"
"git.zb-server.de/ZB-Server/uptimesebi/internal/statuspage" "git.zb-server.de/ZB-Server/uptimesebi/internal/statuspage"
"git.zb-server.de/ZB-Server/uptimesebi/internal/store"
"git.zb-server.de/ZB-Server/uptimesebi/internal/tenant"
) )
func TestCertStorage(t *testing.T) { func TestCertStorage(t *testing.T) {
e := newEnv(t) e := newEnv(t)
ctx := context.Background() ctx := context.Background()
platform := statuspage.NewCertStorage(e.statuspageClient(t, nil)) platform := statuspage.NewCertStorage(e.statuspageClient(t, nil), "")
base := "certificates/" + uuid.NewString()[:8] base := "certificates/" + uuid.NewString()[:8]
key := base + "/example.com/example.com.key" key := base + "/example.com/example.com.key"
@@ -60,7 +64,7 @@ func TestCertStorage(t *testing.T) {
other := e.browser(t) other := e.browser(t)
other.signup("x@"+uniq("cs")+".test", uniq("cs-")) other.signup("x@"+uniq("cs")+".test", uniq("cs-"))
org := uuid.MustParse(other.orgID()) org := uuid.MustParse(other.orgID())
orgStore := statuspage.NewCertStorage(e.statuspageClient(t, &org)) orgStore := statuspage.NewCertStorage(e.statuspageClient(t, &org), "")
if _, err := orgStore.Load(ctx, key); !errors.Is(err, fs.ErrNotExist) { if _, err := orgStore.Load(ctx, key); !errors.Is(err, fs.ErrNotExist) {
t.Errorf("org server loaded a platform key: %v", err) t.Errorf("org server loaded a platform key: %v", err)
} }
@@ -100,7 +104,10 @@ func TestAllowCertificate(t *testing.T) {
record := body["domain_record"].(map[string]any) record := body["domain_record"].(map[string]any)
cat, _ := i18n.Load() cat, _ := i18n.Load()
srv := statuspage.New(e.statuspageClient(t, nil), cat, slog.New(slog.DiscardHandler), []string{"status.test"}) srv, err := statuspage.New(e.statuspageClient(t, nil), cat, slog.New(slog.DiscardHandler), statuspage.Options{Hosts: []string{"status.test"}})
if err != nil {
t.Fatal(err)
}
ctx := context.Background() ctx := context.Background()
if err := srv.AllowCertificate(ctx, "status.test"); err != nil { if err := srv.AllowCertificate(ctx, "status.test"); err != nil {
t.Errorf("AllowCertificate(default host) = %v", err) t.Errorf("AllowCertificate(default host) = %v", err)
@@ -116,3 +123,33 @@ func TestAllowCertificate(t *testing.T) {
t.Errorf("AllowCertificate(verified domain) = %v", err) t.Errorf("AllowCertificate(verified domain) = %v", err)
} }
} }
// TestCertStorageMirror loads certificates from the local mirror when the
// API is unreachable, as after a restart during an outage.
func TestCertStorageMirror(t *testing.T) {
e := newEnv(t)
ctx := context.Background()
dir := t.TempDir()
tok, params := api.NewAgentToken(nil, "statuspage", "mirror", nil)
if err := tenant.New(e.dbPool).Tx(ctx, tenant.System(), func(q *store.Queries) error {
_, err := q.CreateAgent(ctx, params)
return err
}); err != nil {
t.Fatal(err)
}
online := statuspage.NewCertStorage(agentapi.NewClient(e.srv.URL, tok, uuid.New(), "t").WithHTTPClient(e.srv.Client()), dir)
key := "certificates/acme/example.com/example.com.crt"
if err := online.Store(ctx, key, []byte("cert")); err != nil {
t.Fatal(err)
}
offline := statuspage.NewCertStorage(agentapi.NewClient("https://127.0.0.1:1", tok, uuid.New(), "t"), dir)
if got, err := offline.Load(ctx, key); err != nil || string(got) != "cert" {
t.Errorf("Load() with API down = %q, %v; want mirrored value", got, err)
}
if !offline.Exists(ctx, key) {
t.Error("Exists() with API down = false, want true from mirror")
}
if _, err := offline.Load(ctx, "../../etc/passwd"); err == nil {
t.Error("Load() escaped the mirror directory")
}
}
+4
View File
@@ -147,6 +147,10 @@ type StatusPage struct {
// Hosts are the host names that serve pages by slug, e.g. // Hosts are the host names that serve pages by slug, e.g.
// status.example.com. Any other host is treated as a custom domain. // status.example.com. Any other host is treated as a custom domain.
Hosts []string `env:"UPTIME_STATUSPAGE_HOSTS" envSeparator:"," envDefault:"localhost"` Hosts []string `env:"UPTIME_STATUSPAGE_HOSTS" envSeparator:"," envDefault:"localhost"`
// CacheDir keeps snapshots and certificates so pages survive restarts
// while the API is down. Defaults to the user cache directory; on
// Kubernetes mount a persistent volume or at least an emptyDir.
CacheDir string `env:"UPTIME_STATUSPAGE_CACHE_DIR"`
// TLS obtains certificates via ACME for the hosts and verified custom // TLS obtains certificates via ACME for the hosts and verified custom
// domains and serves HTTPS on TLSListen; Listen then answers ACME HTTP // domains and serves HTTPS on TLSListen; Listen then answers ACME HTTP
// challenges and redirects to HTTPS. // challenges and redirects to HTTPS.
+1
View File
@@ -223,6 +223,7 @@
}, },
"page.incidents": "Letzte Vorfälle", "page.incidents": "Letzte Vorfälle",
"page.no_incidents": "Keine Vorfälle in den letzten 14 Tagen.", "page.no_incidents": "Keine Vorfälle in den letzten 14 Tagen.",
"page.stale": "Live-Aktualisierung derzeit nicht verfügbar. Diese Seite zeigt den Stand von {{.Time}}.",
"page.status.degraded": "Einige Systeme haben Probleme", "page.status.degraded": "Einige Systeme haben Probleme",
"page.status.operational": "Alle Systeme funktionieren", "page.status.operational": "Alle Systeme funktionieren",
"page.status.outage": "Größere Störung", "page.status.outage": "Größere Störung",
+1
View File
@@ -223,6 +223,7 @@
}, },
"page.incidents": "Recent incidents", "page.incidents": "Recent incidents",
"page.no_incidents": "No incidents in the last 14 days.", "page.no_incidents": "No incidents in the last 14 days.",
"page.stale": "Live updates are currently unavailable. This page shows the status as of {{.Time}}.",
"page.status.degraded": "Some systems are experiencing problems", "page.status.degraded": "Some systems are experiencing problems",
"page.status.operational": "All systems operational", "page.status.operational": "All systems operational",
"page.status.outage": "Major outage", "page.status.outage": "Major outage",
+196 -36
View File
@@ -1,15 +1,26 @@
// Package statuspage serves public status pages from snapshots fetched // Package statuspage serves public status pages from snapshots fetched
// through the agent API. It keeps a short in-memory cache and keeps serving // through the agent API.
// the last snapshot for a while if the API is unreachable, so a page stays //
// up during the incidents it is meant to report. // A status page has to stay up during the incidents it reports, including
// an outage of the API itself. Every snapshot is therefore kept in memory
// and on disk, requests are answered from that copy without waiting for the
// API, known pages are refreshed in the background, and the last known state
// is served for as long as the API stays unreachable, survives restarts and
// is marked as outdated once it ages. Only an explicit "not found" from the
// API removes a page.
package statuspage package statuspage
import ( import (
"context" "context"
"crypto/sha256"
"encoding/hex"
"encoding/json"
"errors" "errors"
"log/slog" "log/slog"
"net" "net"
"net/http" "net/http"
"os"
"path/filepath"
"strings" "strings"
"sync" "sync"
"time" "time"
@@ -22,8 +33,11 @@ import (
) )
const ( const (
// freshFor is how long a snapshot is used without asking the API.
freshFor = 30 * time.Second freshFor = 30 * time.Second
staleFor = 10 * time.Minute // staleNoticeAfter is when visitors are told the state may be outdated.
staleNoticeAfter = 5 * time.Minute
refreshInterval = 30 * time.Second
) )
// Source fetches snapshots; *agentapi.Client implements it. // Source fetches snapshots; *agentapi.Client implements it.
@@ -39,27 +53,107 @@ type Server struct {
// ownHosts are the hosts that serve pages by slug; any other host is // ownHosts are the hosts that serve pages by slug; any other host is
// looked up as a custom domain. // looked up as a custom domain.
ownHosts map[string]bool ownHosts map[string]bool
now func() time.Time // dir persists snapshots; empty keeps them in memory only.
dir string
now func() time.Time
mu sync.Mutex mu sync.Mutex
cache map[string]entry cache map[string]entry
refreshing map[string]bool
} }
// entry is one cached page, also its on-disk form.
type entry struct { type entry struct {
snap agentapi.PageSnapshot Key string `json:"key"`
missing bool Host string `json:"host,omitempty"`
fetched time.Time Slug string `json:"slug,omitempty"`
Snap agentapi.PageSnapshot `json:"snapshot"`
Fetched time.Time `json:"fetched"`
} }
// New returns a Server. ownHosts lists the host names of the default // Options configure a Server.
// domain, e.g. "status.example.com"; requests to other hosts are matched type Options struct {
// against verified custom domains. // Hosts are the host names of the default domain, e.g.
func New(src Source, catalog *i18n.Catalog, log *slog.Logger, ownHosts []string) *Server { // "status.example.com"; requests to other hosts are matched against
s := &Server{src: src, catalog: catalog, log: log, ownHosts: map[string]bool{}, now: time.Now, cache: map[string]entry{}} // verified custom domains.
for _, h := range ownHosts { Hosts []string
// CacheDir persists snapshots across restarts. Empty disables
// persistence, which loses all pages on restart.
CacheDir string
}
// New returns a Server and loads snapshots persisted in o.CacheDir.
func New(src Source, catalog *i18n.Catalog, log *slog.Logger, o Options) (*Server, error) {
s := &Server{
src: src, catalog: catalog, log: log, ownHosts: map[string]bool{}, dir: o.CacheDir,
now: time.Now, cache: map[string]entry{}, refreshing: map[string]bool{},
}
for _, h := range o.Hosts {
s.ownHosts[strings.ToLower(h)] = true s.ownHosts[strings.ToLower(h)] = true
} }
return s if s.dir != "" {
if err := os.MkdirAll(s.dir, 0o700); err != nil {
return nil, err
}
if err := s.loadDisk(); err != nil {
return nil, err
}
}
return s, nil
}
func (s *Server) loadDisk() error {
files, err := filepath.Glob(filepath.Join(s.dir, "*.json"))
if err != nil {
return err
}
for _, f := range files {
raw, err := os.ReadFile(f)
if err != nil {
return err
}
var e entry
if err := json.Unmarshal(raw, &e); err != nil || e.Key == "" {
s.log.Warn("ignoring unreadable cached page", "file", f, "error", err)
continue
}
s.cache[e.Key] = e
}
if len(s.cache) > 0 {
s.log.Info("loaded cached status pages", "count", len(s.cache))
}
return nil
}
func (s *Server) fileFor(key string) string {
sum := sha256.Sum256([]byte(key))
return filepath.Join(s.dir, hex.EncodeToString(sum[:16])+".json")
}
// persist writes atomically so a crash never leaves a truncated snapshot.
func (s *Server) persist(e entry) {
if s.dir == "" {
return
}
raw, err := json.Marshal(e)
if err == nil {
tmp := s.fileFor(e.Key) + ".tmp"
if err = os.WriteFile(tmp, raw, 0o600); err == nil {
err = os.Rename(tmp, s.fileFor(e.Key))
}
}
if err != nil {
s.log.Warn("persisting status page failed", "page", e.Key, "error", err)
}
}
func (s *Server) forget(key string) {
s.mu.Lock()
delete(s.cache, key)
s.mu.Unlock()
if s.dir != "" {
_ = os.Remove(s.fileFor(key))
}
} }
// Mount registers the page routes. // Mount registers the page routes.
@@ -67,6 +161,19 @@ func (s *Server) Mount(r *gin.Engine) {
r.NoRoute(s.serve) r.NoRoute(s.serve)
} }
// Ready reports whether the server can answer visitors: either the API is
// reachable or pages are cached. A status page server must not drop out of
// the load balancer just because the API is down.
func (s *Server) Ready(ctx context.Context, apiProbe func(context.Context) error) error {
s.mu.Lock()
cached := len(s.cache)
s.mu.Unlock()
if cached > 0 {
return nil
}
return apiProbe(ctx)
}
// IsCustomDomain reports whether host is served as a custom domain. // IsCustomDomain reports whether host is served as a custom domain.
func (s *Server) IsCustomDomain(host string) bool { func (s *Server) IsCustomDomain(host string) bool {
return !s.ownHosts[hostOnly(host)] return !s.ownHosts[hostOnly(host)]
@@ -99,45 +206,98 @@ func (s *Server) serve(c *gin.Context) {
c.Status(http.StatusNotFound) c.Status(http.StatusNotFound)
return return
} }
key = "slug:" + slug key, host = "slug:"+slug, ""
host = ""
} }
snap, ok := s.snapshot(c.Request.Context(), key, host, slug) e, ok := s.lookup(c.Request.Context(), key, host, slug)
if !ok { if !ok {
c.Status(http.StatusNotFound) c.Status(http.StatusNotFound)
return return
} }
var staleSince time.Time
if s.now().Sub(e.Fetched) > staleNoticeAfter {
staleSince = e.Fetched
}
l := s.catalog.Match(c.GetHeader("Accept-Language")) l := s.catalog.Match(c.GetHeader("Accept-Language"))
c.Request = c.Request.WithContext(i18n.NewContext(c.Request.Context(), l)) c.Request = c.Request.WithContext(i18n.NewContext(c.Request.Context(), l))
c.Header("Cache-Control", "public, max-age=30") c.Header("Cache-Control", "public, max-age=30")
c.Header("Content-Language", l.Lang()) c.Header("Content-Language", l.Lang())
web.Render(c, http.StatusOK, web.PublicStatusPage(snap, web.PublicAssets{CSSHref: "/static/dist/app.css"})) web.Render(c, http.StatusOK, web.PublicStatusPage(e.Snap, web.PublicAssets{CSSHref: "/static/dist/app.css", StaleSince: staleSince}))
} }
func (s *Server) snapshot(ctx context.Context, key, host, slug string) (agentapi.PageSnapshot, bool) { // lookup answers from the cache whenever possible and refreshes in the
now := s.now() // background; only unknown pages wait for the API.
func (s *Server) lookup(ctx context.Context, key, host, slug string) (entry, bool) {
s.mu.Lock() s.mu.Lock()
e, cached := s.cache[key] e, cached := s.cache[key]
s.mu.Unlock() s.mu.Unlock()
if cached && now.Sub(e.fetched) < freshFor { if cached {
return e.snap, !e.missing if s.now().Sub(e.Fetched) >= freshFor {
go s.refresh(context.WithoutCancel(ctx), key, host, slug)
}
return e, true
} }
return s.fetch(ctx, key, host, slug)
}
func (s *Server) fetch(ctx context.Context, key, host, slug string) (entry, bool) {
snap, err := s.src.Page(ctx, host, slug) snap, err := s.src.Page(ctx, host, slug)
switch { switch {
case err == nil:
e = entry{snap: snap, fetched: now}
case errors.Is(err, agentapi.ErrNotFound): case errors.Is(err, agentapi.ErrNotFound):
e = entry{missing: true, fetched: now} s.forget(key)
default: return entry{}, false
if cached && now.Sub(e.fetched) < staleFor { case err != nil:
s.log.WarnContext(ctx, "serving stale status page", "page", key, "error", err) s.log.WarnContext(ctx, "fetching status page failed", "page", key, "error", err)
return e.snap, !e.missing s.mu.Lock()
} e, ok := s.cache[key]
s.log.ErrorContext(ctx, "fetching status page failed", "page", key, "error", err) s.mu.Unlock()
return agentapi.PageSnapshot{}, false return e, ok
} }
e := entry{Key: key, Host: host, Slug: slug, Snap: snap, Fetched: s.now()}
s.mu.Lock() s.mu.Lock()
s.cache[key] = e s.cache[key] = e
s.mu.Unlock() s.mu.Unlock()
return e.snap, !e.missing s.persist(e)
return e, true
}
// refresh fetches key unless another refresh of it is running.
func (s *Server) refresh(ctx context.Context, key, host, slug string) {
s.mu.Lock()
if s.refreshing[key] {
s.mu.Unlock()
return
}
s.refreshing[key] = true
s.mu.Unlock()
defer func() {
s.mu.Lock()
delete(s.refreshing, key)
s.mu.Unlock()
}()
ctx, cancel := context.WithTimeout(ctx, 15*time.Second)
defer cancel()
s.fetch(ctx, key, host, slug)
}
// Run keeps every known page fresh until ctx ends, so pages stay current
// even without visitors and the cache is warm when the API goes away.
func (s *Server) Run(ctx context.Context) {
tick := time.NewTicker(refreshInterval)
defer tick.Stop()
for {
select {
case <-ctx.Done():
return
case <-tick.C:
s.mu.Lock()
entries := make([]entry, 0, len(s.cache))
for _, e := range s.cache {
entries = append(entries, e)
}
s.mu.Unlock()
for _, e := range entries {
s.refresh(ctx, e.Key, e.Host, e.Slug)
}
}
}
} }
+146 -30
View File
@@ -7,6 +7,7 @@ import (
"net/http" "net/http"
"net/http/httptest" "net/http/httptest"
"strings" "strings"
"sync"
"testing" "testing"
"time" "time"
@@ -17,53 +18,92 @@ import (
) )
type fakeSource struct { type fakeSource struct {
mu sync.Mutex
calls int calls int
err error err error
delay time.Duration
pages map[string]agentapi.PageSnapshot pages map[string]agentapi.PageSnapshot
} }
func (f *fakeSource) Page(_ context.Context, host, slug string) (agentapi.PageSnapshot, error) { func (f *fakeSource) Page(ctx context.Context, host, slug string) (agentapi.PageSnapshot, error) {
f.mu.Lock()
f.calls++ f.calls++
if f.err != nil { err, delay, p, ok := f.err, f.delay, f.pages[host+"|"+slug], false
return agentapi.PageSnapshot{}, f.err if _, exists := f.pages[host+"|"+slug]; exists {
ok = true
}
f.mu.Unlock()
if delay > 0 {
select {
case <-time.After(delay):
case <-ctx.Done():
return p, ctx.Err()
}
}
if err != nil {
return agentapi.PageSnapshot{}, err
} }
p, ok := f.pages[host+"|"+slug]
if !ok { if !ok {
return p, agentapi.ErrNotFound return p, agentapi.ErrNotFound
} }
return p, nil return p, nil
} }
func newTest(t *testing.T) (*Server, *fakeSource, *gin.Engine, *time.Time) { func (f *fakeSource) set(fn func(*fakeSource)) {
f.mu.Lock()
defer f.mu.Unlock()
fn(f)
}
func (f *fakeSource) callCount() int {
f.mu.Lock()
defer f.mu.Unlock()
return f.calls
}
type harness struct {
srv *Server
src *fakeSource
r *gin.Engine
now *time.Time
}
func newHarness(t *testing.T, src *fakeSource, dir string, now *time.Time) harness {
t.Helper() t.Helper()
cat, err := i18n.Load() cat, err := i18n.Load()
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
src := &fakeSource{pages: map[string]agentapi.PageSnapshot{ s, err := New(src, cat, slog.New(slog.DiscardHandler), Options{Hosts: []string{"status.example.test"}, CacheDir: dir})
"|acme": {Title: "Acme status", Status: agentapi.PageOperational}, if err != nil {
"status.acme.test|": {Title: "Acme on own domain", Status: agentapi.PageOutage}, t.Fatal(err)
}} }
s := New(src, cat, slog.New(slog.DiscardHandler), []string{"status.example.test"}) s.now = func() time.Time { return *now }
now := time.Now()
s.now = func() time.Time { return now }
gin.SetMode(gin.TestMode) gin.SetMode(gin.TestMode)
r := gin.New() r := gin.New()
s.Mount(r) s.Mount(r)
return s, src, r, &now return harness{srv: s, src: src, r: r, now: now}
} }
func get(r http.Handler, host, path string) (int, string) { func newSource() *fakeSource {
return &fakeSource{pages: map[string]agentapi.PageSnapshot{
"|acme": {Title: "Acme status", Status: agentapi.PageOperational},
"status.acme.test|": {Title: "Acme on own domain", Status: agentapi.PageOutage},
}}
}
func (h harness) get(host, path string) (int, string) {
req := httptest.NewRequest(http.MethodGet, path, nil) req := httptest.NewRequest(http.MethodGet, path, nil)
req.Host = host req.Host = host
req.Header.Set("Accept-Language", "de") req.Header.Set("Accept-Language", "de")
w := httptest.NewRecorder() w := httptest.NewRecorder()
r.ServeHTTP(w, req) h.r.ServeHTTP(w, req)
return w.Code, w.Body.String() return w.Code, w.Body.String()
} }
func TestRouting(t *testing.T) { func TestRouting(t *testing.T) {
_, _, r, _ := newTest(t) now := time.Now()
h := newHarness(t, newSource(), t.TempDir(), &now)
tests := []struct { tests := []struct {
host, path string host, path string
want int want int
@@ -78,27 +118,103 @@ func TestRouting(t *testing.T) {
{"other.test", "/", 404, ""}, {"other.test", "/", 404, ""},
} }
for _, tt := range tests { for _, tt := range tests {
code, body := get(r, tt.host, tt.path) code, body := h.get(tt.host, tt.path)
if code != tt.want || !strings.Contains(body, tt.contains) { if code != tt.want || !strings.Contains(body, tt.contains) {
t.Errorf("GET %s%s = %d (contains %q: %t), want %d", tt.host, tt.path, code, tt.contains, strings.Contains(body, tt.contains), tt.want) t.Errorf("GET %s%s = %d (contains %q: %t), want %d", tt.host, tt.path, code, tt.contains, strings.Contains(body, tt.contains), tt.want)
} }
} }
} }
func TestCacheAndStaleFallback(t *testing.T) { // TestSurvivesAPIOutageAndRestart is the reason this package keeps state:
_, src, r, now := newTest(t) // the page must stay up while the API is down, also across restarts.
get(r, "status.example.test", "/acme") func TestSurvivesAPIOutageAndRestart(t *testing.T) {
get(r, "status.example.test", "/acme") dir := t.TempDir()
if src.calls != 1 { now := time.Now()
t.Errorf("source calls within freshness window = %d, want 1", src.calls) h := newHarness(t, newSource(), dir, &now)
if code, _ := h.get("status.example.test", "/acme"); code != 200 {
t.Fatalf("first GET = %d", code)
} }
src.err = errors.New("api down")
*now = now.Add(time.Minute) down := &fakeSource{err: errors.New("connection refused")}
if code, body := get(r, "status.example.test", "/acme"); code != 200 || !strings.Contains(body, "Acme status") { now = now.Add(time.Minute)
t.Errorf("GET with API down = %d, want stale page", code) restarted := newHarness(t, down, dir, &now)
if code, body := restarted.get("status.example.test", "/acme"); code != 200 || !strings.Contains(body, "Acme status") || strings.Contains(body, "Live-Aktualisierung") {
t.Errorf("GET after restart with API down = %d, want cached page without stale notice", code)
} }
*now = now.Add(time.Hour) if err := restarted.srv.Ready(context.Background(), func(context.Context) error { return errors.New("api down") }); err != nil {
if code, _ := get(r, "status.example.test", "/acme"); code != 404 { t.Errorf("Ready() with cached pages and API down = %v, want ready", err)
t.Errorf("GET with API down long after = %d, want 404", code) }
now = now.Add(72 * time.Hour)
code, body := restarted.get("status.example.test", "/acme")
if code != 200 || !strings.Contains(body, "Live-Aktualisierung") {
t.Errorf("GET three days into the outage = %d, want cached page with stale notice", code)
}
}
func TestReadyWithoutCacheNeedsAPI(t *testing.T) {
now := time.Now()
h := newHarness(t, newSource(), t.TempDir(), &now)
if err := h.srv.Ready(context.Background(), func(context.Context) error { return errors.New("api down") }); err == nil {
t.Error("Ready() with empty cache and API down = nil, want error")
}
}
func TestCachedPagesDoNotWaitForAPI(t *testing.T) {
now := time.Now()
src := newSource()
h := newHarness(t, src, t.TempDir(), &now)
h.get("status.example.test", "/acme")
src.set(func(f *fakeSource) { f.delay = 5 * time.Second })
now = now.Add(time.Minute)
start := time.Now()
if code, _ := h.get("status.example.test", "/acme"); code != 200 {
t.Fatalf("GET = %d", code)
}
if took := time.Since(start); took > time.Second {
t.Errorf("GET with a hanging API took %v, want an immediate cached answer", took)
}
}
func TestBackgroundRefresh(t *testing.T) {
now := time.Now()
src := newSource()
h := newHarness(t, src, t.TempDir(), &now)
h.get("status.example.test", "/acme")
src.set(func(f *fakeSource) {
f.pages["|acme"] = agentapi.PageSnapshot{Title: "Renamed", Status: agentapi.PageOperational}
})
now = now.Add(time.Minute)
h.get("status.example.test", "/acme") // served from cache, triggers refresh
deadline := time.Now().Add(2 * time.Second)
for {
_, body := h.get("status.example.test", "/acme")
if strings.Contains(body, "Renamed") {
break
}
if time.Now().After(deadline) {
t.Fatal("cached page was not refreshed in the background")
}
time.Sleep(20 * time.Millisecond)
}
}
func TestDeletedPageDisappears(t *testing.T) {
dir := t.TempDir()
now := time.Now()
src := newSource()
h := newHarness(t, src, dir, &now)
h.get("status.example.test", "/acme")
src.set(func(f *fakeSource) { delete(f.pages, "|acme") })
now = now.Add(time.Minute)
h.srv.refresh(context.Background(), "slug:acme", "", "acme")
if code, _ := h.get("status.example.test", "/acme"); code != 404 {
t.Errorf("GET after the API reported the page gone = %d, want 404", code)
}
restarted := newHarness(t, &fakeSource{err: errors.New("down")}, dir, &now)
if code, _ := restarted.get("status.example.test", "/acme"); code != 404 {
t.Errorf("GET after restart = %d, want 404 (removed from disk too)", code)
} }
} }
+68 -9
View File
@@ -5,6 +5,8 @@ import (
"errors" "errors"
"fmt" "fmt"
"io/fs" "io/fs"
"os"
"path/filepath"
"time" "time"
"github.com/caddyserver/certmagic" "github.com/caddyserver/certmagic"
@@ -13,15 +15,43 @@ import (
) )
// CertStorage keeps certmagic's certificates and locks in the API, so every // CertStorage keeps certmagic's certificates and locks in the API, so every
// instance of a status page server shares them without a database. // instance of a status page server shares them without a database. Values
// are mirrored to a local directory and read from there when the API is
// unreachable, so HTTPS keeps working after a restart during an outage.
type CertStorage struct { type CertStorage struct {
c *agentapi.Client c *agentapi.Client
dir string
} }
var _ certmagic.Storage = CertStorage{} var _ certmagic.Storage = CertStorage{}
// NewCertStorage returns storage backed by c. // NewCertStorage returns storage backed by c, mirrored to dir unless dir is
func NewCertStorage(c *agentapi.Client) CertStorage { return CertStorage{c: c} } // empty.
func NewCertStorage(c *agentapi.Client, dir string) CertStorage { return CertStorage{c: c, dir: dir} }
// local maps a storage key to a file below dir. Keys come from certmagic,
// but are cleaned anyway so they cannot point outside dir.
func (s CertStorage) local(key string) string {
if s.dir == "" {
return ""
}
clean := filepath.Clean("/" + key)
return filepath.Join(s.dir, filepath.FromSlash(clean))
}
func (s CertStorage) mirror(key string, value []byte) {
if p := s.local(key); p != "" {
if os.MkdirAll(filepath.Dir(p), 0o700) == nil {
_ = os.WriteFile(p, value, 0o600)
}
}
}
// unreachable reports errors that mean the API could not answer, as
// opposed to answers such as "not found".
func unreachable(err error) bool {
return err != nil && !errors.Is(err, agentapi.ErrNotFound) && !errors.Is(err, agentapi.ErrLocked)
}
func notExist(err error) error { func notExist(err error) error {
if errors.Is(err, agentapi.ErrNotFound) { if errors.Is(err, agentapi.ErrNotFound) {
@@ -32,23 +62,43 @@ func notExist(err error) error {
// Store implements certmagic.Storage. // Store implements certmagic.Storage.
func (s CertStorage) Store(ctx context.Context, key string, value []byte) error { func (s CertStorage) Store(ctx context.Context, key string, value []byte) error {
return s.c.StoragePut(ctx, key, value) if err := s.c.StoragePut(ctx, key, value); err != nil {
return err
}
s.mirror(key, value)
return nil
} }
// Load implements certmagic.Storage. // Load implements certmagic.Storage.
func (s CertStorage) Load(ctx context.Context, key string) ([]byte, error) { func (s CertStorage) Load(ctx context.Context, key string) ([]byte, error) {
v, err := s.c.StorageGet(ctx, key) v, err := s.c.StorageGet(ctx, key)
return v, notExist(err) switch {
case err == nil:
s.mirror(key, v)
return v, nil
case unreachable(err) && s.local(key) != "":
if local, lerr := os.ReadFile(s.local(key)); lerr == nil {
return local, nil
}
}
return nil, notExist(err)
} }
// Delete implements certmagic.Storage. // Delete implements certmagic.Storage.
func (s CertStorage) Delete(ctx context.Context, key string) error { func (s CertStorage) Delete(ctx context.Context, key string) error {
if p := s.local(key); p != "" {
_ = os.RemoveAll(p)
}
return notExist(s.c.StorageDelete(ctx, key)) return notExist(s.c.StorageDelete(ctx, key))
} }
// Exists implements certmagic.Storage. // Exists implements certmagic.Storage.
func (s CertStorage) Exists(ctx context.Context, key string) bool { func (s CertStorage) Exists(ctx context.Context, key string) bool {
_, err := s.c.StorageStat(ctx, key) _, err := s.c.StorageStat(ctx, key)
if unreachable(err) && s.local(key) != "" {
_, lerr := os.Stat(s.local(key))
return lerr == nil
}
return err == nil return err == nil
} }
@@ -64,6 +114,11 @@ func (s CertStorage) List(ctx context.Context, path string, recursive bool) ([]s
// Stat implements certmagic.Storage. // Stat implements certmagic.Storage.
func (s CertStorage) Stat(ctx context.Context, key string) (certmagic.KeyInfo, error) { func (s CertStorage) Stat(ctx context.Context, key string) (certmagic.KeyInfo, error) {
info, err := s.c.StorageStat(ctx, key) info, err := s.c.StorageStat(ctx, key)
if unreachable(err) && s.local(key) != "" {
if fi, lerr := os.Stat(s.local(key)); lerr == nil {
return certmagic.KeyInfo{Key: key, Modified: fi.ModTime(), Size: fi.Size(), IsTerminal: !fi.IsDir()}, nil
}
}
if err != nil { if err != nil {
return certmagic.KeyInfo{}, notExist(err) return certmagic.KeyInfo{}, notExist(err)
} }
@@ -100,12 +155,16 @@ func (s CertStorage) Unlock(ctx context.Context, name string) error {
// demand: only for the default hosts and for verified custom domains of // demand: only for the default hosts and for verified custom domains of
// pages this server may serve. Anything else would let strangers make us // pages this server may serve. Anything else would let strangers make us
// request certificates for arbitrary names. // request certificates for arbitrary names.
//
// Names with a cached page are allowed without asking the API, so existing
// certificates can be loaded after a restart while the API is down.
func (s *Server) AllowCertificate(ctx context.Context, name string) error { func (s *Server) AllowCertificate(ctx context.Context, name string) error {
if s.ownHosts[hostOnly(name)] { host := hostOnly(name)
if s.ownHosts[host] {
return nil return nil
} }
if _, err := s.src.Page(ctx, hostOnly(name), ""); err != nil { if _, ok := s.lookup(ctx, "host:"+host, host, ""); !ok {
return fmt.Errorf("no status page for %s: %w", name, err) return fmt.Errorf("no status page for %s", name)
} }
return nil return nil
} }
+4
View File
@@ -2,6 +2,7 @@ package web
import ( import (
"io/fs" "io/fs"
"time"
"git.zb-server.de/ZB-Server/uptimesebi/internal/agentapi" "git.zb-server.de/ZB-Server/uptimesebi/internal/agentapi"
) )
@@ -11,6 +12,9 @@ import (
type PublicAssets struct { type PublicAssets struct {
CSSHref string CSSHref string
InlineCSS string InlineCSS string
// StaleSince, if set, tells visitors that live updates are unavailable
// and the page shows the state of that moment.
StaleSince time.Time
} }
// StylesheetText returns the built stylesheet for inlining. // StylesheetText returns the built stylesheet for inlining.
+5
View File
@@ -38,6 +38,11 @@ templ PublicStatusPage(s agentapi.PageSnapshot, a PublicAssets) {
<p class="mt-2 text-muted">{ s.Description }</p> <p class="mt-2 text-muted">{ s.Description }</p>
} }
</header> </header>
if !a.StaleSince.IsZero() {
<p class="mb-6 border border-degraded/50 bg-degraded/10 px-4 py-2 text-sm">
{ i18n.T(ctx, "page.stale", "Time", a.StaleSince.UTC().Format("2006-01-02 15:04")+" UTC") }
</p>
}
<section <section
class={ "mb-12 border-l-4 py-3 pl-4", class={ "mb-12 border-l-4 py-3 pl-4",
templ.KV("border-up", s.Status == agentapi.PageOperational), templ.KV("border-up", s.Status == agentapi.PageOperational),
+145 -126
View File
@@ -175,33 +175,52 @@ func PublicStatusPage(s agentapi.PageSnapshot, a PublicAssets) templ.Component {
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
if !a.StaleSince.IsZero() {
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 15, "<p class=\"mb-6 border border-degraded/50 bg-degraded/10 px-4 py-2 text-sm\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var9 string
templ_7745c5c3_Var9, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "page.stale", "Time", a.StaleSince.UTC().Format("2006-01-02 15:04")+" UTC"))
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/public.templ`, Line: 43, Col: 95}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var9))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 16, "</p>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
}
{ {
templ_7745c5c3_ElementWriter := templ_7745c5c3_Buffer templ_7745c5c3_ElementWriter := templ_7745c5c3_Buffer
templ_7745c5c3_Buffer := templ.GetBuffer() templ_7745c5c3_Buffer := templ.GetBuffer()
var templ_7745c5c3_ElementScripts []templ.ComponentScript var templ_7745c5c3_ElementScripts []templ.ComponentScript
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 15, "<section class=\"") templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 17, "<section class=\"")
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
var templ_7745c5c3_Var9 = []any{"mb-12 border-l-4 py-3 pl-4", var templ_7745c5c3_Var10 = []any{"mb-12 border-l-4 py-3 pl-4",
templ.KV("border-up", s.Status == agentapi.PageOperational), templ.KV("border-up", s.Status == agentapi.PageOperational),
templ.KV("border-degraded", s.Status == agentapi.PageDegraded), templ.KV("border-degraded", s.Status == agentapi.PageDegraded),
templ.KV("border-down", s.Status == agentapi.PageOutage), templ.KV("border-down", s.Status == agentapi.PageOutage),
templ.KV("border-unknown", s.Status == agentapi.PageUnknown)} templ.KV("border-unknown", s.Status == agentapi.PageUnknown)}
templ_7745c5c3_Err = templ.RenderCSSItems(ctx, templ_7745c5c3_ElementWriter, templ_7745c5c3_Var9...) templ_7745c5c3_Err = templ.RenderCSSItems(ctx, templ_7745c5c3_ElementWriter, templ_7745c5c3_Var10...)
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
var templ_7745c5c3_Var10 string var templ_7745c5c3_Var11 string
templ_7745c5c3_Var10, templ_7745c5c3_Err = templruntime.NewAttributeExpression(templ.CSSClasses(templ_7745c5c3_Var9).String()).Resolve(ctx) templ_7745c5c3_Var11, templ_7745c5c3_Err = templruntime.NewAttributeExpression(templ.CSSClasses(templ_7745c5c3_Var10).String()).Resolve(ctx)
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/public.templ`, Line: 1, Col: 0} return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/public.templ`, Line: 1, Col: 0}
} }
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var10) _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var11)
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 16, "\"") templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 18, "\"")
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
@@ -215,53 +234,53 @@ func PublicStatusPage(s agentapi.PageSnapshot, a PublicAssets) templ.Component {
} }
templ.ReleaseBuffer(templ_7745c5c3_Buffer) templ.ReleaseBuffer(templ_7745c5c3_Buffer)
} }
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 17, "><p class=\"text-lg font-medium\">") templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 19, "><p class=\"text-lg font-medium\">")
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
var templ_7745c5c3_Var11 string var templ_7745c5c3_Var12 string
templ_7745c5c3_Var11, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "page.status."+s.Status)) templ_7745c5c3_Var12, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "page.status."+s.Status))
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/public.templ`, Line: 48, Col: 74} return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/public.templ`, Line: 53, Col: 74}
} }
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var11)) _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var12))
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 18, "</p></section>") templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 20, "</p></section>")
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
for _, sec := range s.Sections { for _, sec := range s.Sections {
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 19, "<section class=\"mb-10\">") templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 21, "<section class=\"mb-10\">")
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
if sec.Name != "" { if sec.Name != "" {
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 20, "<h2 class=\"mb-3 text-xs font-medium uppercase tracking-wider text-muted\">") templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 22, "<h2 class=\"mb-3 text-xs font-medium uppercase tracking-wider text-muted\">")
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
var templ_7745c5c3_Var12 string var templ_7745c5c3_Var13 string
templ_7745c5c3_Var12, templ_7745c5c3_Err = templ.JoinStringErrs(sec.Name) templ_7745c5c3_Var13, templ_7745c5c3_Err = templ.JoinStringErrs(sec.Name)
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/public.templ`, Line: 53, Col: 90} return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/public.templ`, Line: 58, Col: 90}
} }
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var12)) _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var13))
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 21, "</h2>") templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 23, "</h2>")
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
} }
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 22, "<ul class=\"divide-y divide-rule border-y border-rule\">") templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 24, "<ul class=\"divide-y divide-rule border-y border-rule\">")
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
for _, comp := range sec.Components { for _, comp := range sec.Components {
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 23, "<li class=\"py-3\"><div class=\"mb-2 flex items-center gap-2.5\">") templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 25, "<li class=\"py-3\"><div class=\"mb-2 flex items-center gap-2.5\">")
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
@@ -269,33 +288,33 @@ func PublicStatusPage(s agentapi.PageSnapshot, a PublicAssets) templ.Component {
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 24, "<span>") templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 26, "<span>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var13 string
templ_7745c5c3_Var13, templ_7745c5c3_Err = templ.JoinStringErrs(comp.Name)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/public.templ`, Line: 60, Col: 27}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var13))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 25, "</span> <span class=\"ml-auto text-sm text-muted\">")
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
var templ_7745c5c3_Var14 string var templ_7745c5c3_Var14 string
templ_7745c5c3_Var14, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "page.component."+comp.Status)) templ_7745c5c3_Var14, templ_7745c5c3_Err = templ.JoinStringErrs(comp.Name)
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/public.templ`, Line: 61, Col: 95} return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/public.templ`, Line: 65, Col: 27}
} }
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var14)) _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var14))
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 26, "</span></div>") templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 27, "</span> <span class=\"ml-auto text-sm text-muted\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var15 string
templ_7745c5c3_Var15, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "page.component."+comp.Status))
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/public.templ`, Line: 66, Col: 95}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var15))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 28, "</span></div>")
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
@@ -303,127 +322,109 @@ func PublicStatusPage(s agentapi.PageSnapshot, a PublicAssets) templ.Component {
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 27, "<div class=\"mt-1 flex justify-between font-mono text-xs text-muted\"><span>") templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 29, "<div class=\"mt-1 flex justify-between font-mono text-xs text-muted\"><span>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var15 string
templ_7745c5c3_Var15, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "page.days_ago", "Count", len(comp.Days)))
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/public.templ`, Line: 65, Col: 71}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var15))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 28, "</span> <span>")
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
var templ_7745c5c3_Var16 string var templ_7745c5c3_Var16 string
templ_7745c5c3_Var16, templ_7745c5c3_Err = templ.JoinStringErrs(UptimeText(comp.Uptime)) templ_7745c5c3_Var16, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "page.days_ago", "Count", len(comp.Days)))
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/public.templ`, Line: 66, Col: 41} return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/public.templ`, Line: 70, Col: 71}
} }
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var16)) _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var16))
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 29, "</span> <span>") templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 30, "</span> <span>")
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
var templ_7745c5c3_Var17 string var templ_7745c5c3_Var17 string
templ_7745c5c3_Var17, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "page.today")) templ_7745c5c3_Var17, templ_7745c5c3_Err = templ.JoinStringErrs(UptimeText(comp.Uptime))
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/public.templ`, Line: 67, Col: 43} return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/public.templ`, Line: 71, Col: 41}
} }
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var17)) _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var17))
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 30, "</span></div></li>") templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 31, "</span> <span>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var18 string
templ_7745c5c3_Var18, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "page.today"))
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/public.templ`, Line: 72, Col: 43}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var18))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 32, "</span></div></li>")
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
} }
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 31, "</ul></section>") templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 33, "</ul></section>")
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
} }
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 32, "<section class=\"mb-12\"><h2 class=\"mb-3 text-xs font-medium uppercase tracking-wider text-muted\">") templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 34, "<section class=\"mb-12\"><h2 class=\"mb-3 text-xs font-medium uppercase tracking-wider text-muted\">")
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
var templ_7745c5c3_Var18 string var templ_7745c5c3_Var19 string
templ_7745c5c3_Var18, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "page.incidents")) templ_7745c5c3_Var19, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "page.incidents"))
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/public.templ`, Line: 75, Col: 109} return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/public.templ`, Line: 80, Col: 109}
} }
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var18)) _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var19))
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 33, "</h2>") templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 35, "</h2>")
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
if len(s.Incidents) == 0 { if len(s.Incidents) == 0 {
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 34, "<p class=\"text-sm text-muted\">") templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 36, "<p class=\"text-sm text-muted\">")
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
var templ_7745c5c3_Var19 string var templ_7745c5c3_Var20 string
templ_7745c5c3_Var19, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "page.no_incidents")) templ_7745c5c3_Var20, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "page.no_incidents"))
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/public.templ`, Line: 77, Col: 70} return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/public.templ`, Line: 82, Col: 70}
} }
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var19)) _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var20))
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 35, "</p>") templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 37, "</p>")
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
} else { } else {
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 36, "<ul class=\"divide-y divide-rule border-y border-rule text-sm\">") templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 38, "<ul class=\"divide-y divide-rule border-y border-rule text-sm\">")
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
for _, inc := range s.Incidents { for _, inc := range s.Incidents {
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 37, "<li class=\"flex flex-wrap items-baseline gap-x-4 gap-y-1 py-2.5\">") templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 39, "<li class=\"flex flex-wrap items-baseline gap-x-4 gap-y-1 py-2.5\">")
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
if inc.ResolvedAt == nil { if inc.ResolvedAt == nil {
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 38, "<span class=\"font-medium text-down\">") templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 40, "<span class=\"font-medium text-down\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var20 string
templ_7745c5c3_Var20, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "incidents.ongoing"))
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/public.templ`, Line: 83, Col: 80}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var20))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 39, "</span> ")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
} else {
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 40, "<span class=\"text-up\">")
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
var templ_7745c5c3_Var21 string var templ_7745c5c3_Var21 string
templ_7745c5c3_Var21, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "incidents.resolved")) templ_7745c5c3_Var21, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "incidents.ongoing"))
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/public.templ`, Line: 85, Col: 67} return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/public.templ`, Line: 88, Col: 80}
} }
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var21)) _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var21))
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
@@ -433,80 +434,98 @@ func PublicStatusPage(s agentapi.PageSnapshot, a PublicAssets) templ.Component {
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
} else {
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 42, "<span class=\"text-up\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var22 string
templ_7745c5c3_Var22, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "incidents.resolved"))
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/public.templ`, Line: 90, Col: 67}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var22))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 43, "</span> ")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
} }
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 42, "<span>") templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 44, "<span>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var22 string
templ_7745c5c3_Var22, templ_7745c5c3_Err = templ.JoinStringErrs(inc.Component)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/public.templ`, Line: 87, Col: 30}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var22))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 43, "</span> <span class=\"ml-auto font-mono text-xs text-muted\">")
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
var templ_7745c5c3_Var23 string var templ_7745c5c3_Var23 string
templ_7745c5c3_Var23, templ_7745c5c3_Err = templ.JoinStringErrs(inc.StartedAt.UTC().Format("2006-01-02 15:04")) templ_7745c5c3_Var23, templ_7745c5c3_Err = templ.JoinStringErrs(inc.Component)
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/public.templ`, Line: 89, Col: 58} return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/public.templ`, Line: 92, Col: 30}
} }
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var23)) _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var23))
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 44, " ") templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 45, "</span> <span class=\"ml-auto font-mono text-xs text-muted\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var24 string
templ_7745c5c3_Var24, templ_7745c5c3_Err = templ.JoinStringErrs(inc.StartedAt.UTC().Format("2006-01-02 15:04"))
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/public.templ`, Line: 94, Col: 58}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var24))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 46, " ")
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
if inc.ResolvedAt != nil { if inc.ResolvedAt != nil {
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 45, "– ") templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 47, "– ")
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
var templ_7745c5c3_Var24 string var templ_7745c5c3_Var25 string
templ_7745c5c3_Var24, templ_7745c5c3_Err = templ.JoinStringErrs(inc.ResolvedAt.UTC().Format("15:04")) templ_7745c5c3_Var25, templ_7745c5c3_Err = templ.JoinStringErrs(inc.ResolvedAt.UTC().Format("15:04"))
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/public.templ`, Line: 91, Col: 53} return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/public.templ`, Line: 96, Col: 53}
} }
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var24)) _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var25))
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 46, " ") templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 48, " ")
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
} }
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 47, "UTC</span></li>") templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 49, "UTC</span></li>")
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
} }
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 48, "</ul>") templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 50, "</ul>")
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
} }
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 49, "</section><footer class=\"flex justify-between border-t border-rule pt-4 font-mono text-xs text-muted\"><span>") templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 51, "</section><footer class=\"flex justify-between border-t border-rule pt-4 font-mono text-xs text-muted\"><span>")
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
var templ_7745c5c3_Var25 string var templ_7745c5c3_Var26 string
templ_7745c5c3_Var25, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "page.updated", "Time", s.GeneratedAt.UTC().Format(time.DateTime)+" UTC")) templ_7745c5c3_Var26, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "page.updated", "Time", s.GeneratedAt.UTC().Format(time.DateTime)+" UTC"))
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/public.templ`, Line: 101, Col: 98} return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/public.templ`, Line: 106, Col: 98}
} }
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var25)) _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var26))
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 50, "</span> <span>uptimesebi</span></footer></main></body></html>") templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 52, "</span> <span>uptimesebi</span></footer></main></body></html>")
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }