From a8200b89c10937cf313aba6a98d1eaabbb8a7ae6 Mon Sep 17 00:00:00 2001 From: Aaron Bieber Date: Sat, 11 May 2024 07:50:03 -0600 Subject: [PATCH] use a context with a timeout --- main.go | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/main.go b/main.go index 9e93eeb..6ba15be 100644 --- a/main.go +++ b/main.go @@ -23,19 +23,23 @@ import ( "tailscale.com/types/logger" ) -//go:embed schema.sql -var schema string +var ( + //go:embed schema.sql + schema string -//go:embed assets -var assets embed.FS + //go:embed assets + assets embed.FS + appCtx, cancel = context.WithTimeout(context.Background(), 3*time.Second) +) var app = &App{ - ctx: context.Background(), + ctx: appCtx, tsServer: &tsnet.Server{}, tsLocalClient: &tailscale.LocalClient{}, } func main() { + defer cancel() name := flag.String("name", "startpage", "name of service") key := flag.String("key", "", "path to file containing the api key") watchInterval := flag.Int64("refresh", 5, "number of minutes between watch refresh")