2021
06-19
06-19
golang 监听服务的信号,实现平滑启动,linux信号说明详解
监听服务的信号,实现平滑启动,linux信号说明packagemainimport("context""fmt""golang.org/x/sync/errgroup""net/http""os""os/signal""syscall")funcmain(){g,ctx:=errgroup.WithContext(context.Background())fmt.Println("服务启动start!")addr:=":9091"s:=&http.Server{Addr:addr,Handler:http.DefaultServeMux,}g.Go(func()error{http.HandleFunc("/test1",func(writerhttp.Respons...
继续阅读 >