Skip to content

Commit

Permalink
repobrowser: pre-warm cache with default URL
Browse files Browse the repository at this point in the history
  • Loading branch information
stapelberg committed May 9, 2020
1 parent a6e47c3 commit f96d98b
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions cmd/distri-repobrowser/repobrowser.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package main

import (
"bytes"
"context"
"database/sql"
"flag"
"log"
Expand Down Expand Up @@ -67,6 +68,16 @@ func logic(listen, assetsDir string) error {
cached: make(map[string]*cachedMetadata),
updates: make(map[string]bool),
}
go func() {
ctx, canc := context.WithTimeout(context.Background(), 5*time.Second)
defer canc()
log.Printf("pre-warming cache")
const defaultURL = "https://repo.distr1.org/distri/jackherer/pkg/meta.binaryproto"
if err := mc.update(ctx, defaultURL, ""); err != nil {
log.Printf("pre-warming %v failed: %v", defaultURL, err)
}
}()

mux := http.NewServeMux()
for _, fn := range []string{
"css/",
Expand Down

0 comments on commit f96d98b

Please sign in to comment.