apply task package

This commit is contained in:
Ronmi Ren 2025-01-13 16:18:52 +08:00
commit a10a04e1ce
4 changed files with 9 additions and 16 deletions

View file

@ -14,6 +14,8 @@ import (
"time"
"git.ronmi.tw/ronmi/forgejo-pages/lib"
"github.com/raohwork/task"
"github.com/raohwork/task/httptask"
"github.com/spf13/cobra"
"github.com/spf13/viper"
)
@ -70,14 +72,7 @@ cache/protection layer like Cloudflare in front of the server.
defer stop()
fmt.Println("starting server")
go func() {
<-ctx.Done()
stop()
ctx, cancel := context.WithTimeout(context.TODO(), 5*time.Second)
defer cancel()
s.Shutdown(ctx)
}()
s.ListenAndServe()
httptask.Server(s, task.Timeout(10*time.Second)).Run(ctx)
},
}