pprofweb/main.go

28 lines
471 B
Go
Raw Normal View History

2023-05-03 05:41:35 +00:00
package main
import (
"context"
"fmt"
"os"
"os/signal"
"syscall"
2023-05-03 05:47:57 +00:00
"tuxpa.in/a/pprofweb/cli"
2023-05-03 05:41:35 +00:00
"github.com/alecthomas/kong"
)
func main() {
ctx := NewCLI()
sctx, cn := signal.NotifyContext(context.Background(), os.Kill, syscall.SIGTERM, syscall.SIGILL)
defer cn()
if err := ctx.Run(cli.Context{Context: sctx}); err != nil {
fmt.Fprintf(os.Stderr, "error: %v\n", err)
os.Exit(1)
}
}
func NewCLI() *kong.Context {
ctx := kong.Parse(&cli.CLI)
return ctx
}