use a context with a timeout

This commit is contained in:
Aaron Bieber 2024-05-11 07:50:03 -06:00
parent 6e28def121
commit a8200b89c1
No known key found for this signature in database

14
main.go
View File

@ -23,19 +23,23 @@ import (
"tailscale.com/types/logger" "tailscale.com/types/logger"
) )
//go:embed schema.sql var (
var schema string //go:embed schema.sql
schema string
//go:embed assets //go:embed assets
var assets embed.FS assets embed.FS
appCtx, cancel = context.WithTimeout(context.Background(), 3*time.Second)
)
var app = &App{ var app = &App{
ctx: context.Background(), ctx: appCtx,
tsServer: &tsnet.Server{}, tsServer: &tsnet.Server{},
tsLocalClient: &tailscale.LocalClient{}, tsLocalClient: &tailscale.LocalClient{},
} }
func main() { func main() {
defer cancel()
name := flag.String("name", "startpage", "name of service") name := flag.String("name", "startpage", "name of service")
key := flag.String("key", "", "path to file containing the api key") key := flag.String("key", "", "path to file containing the api key")
watchInterval := flag.Int64("refresh", 5, "number of minutes between watch refresh") watchInterval := flag.Int64("refresh", 5, "number of minutes between watch refresh")