chanched handlers
This commit is contained in:
@@ -2,13 +2,26 @@ package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"os"
|
||||
"os/signal"
|
||||
"syscall"
|
||||
|
||||
"go.unistack.org/micro/v3/logger"
|
||||
"go.unistack.org/micro/v4/logger"
|
||||
"go.unistack.org/unistack-org/pkgdash/service"
|
||||
)
|
||||
|
||||
func main() {
|
||||
ctx := context.Background()
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
defer cancel()
|
||||
|
||||
ch := make(chan os.Signal, 1)
|
||||
signal.Notify(ch, syscall.SIGINT, syscall.SIGTERM)
|
||||
|
||||
go func() {
|
||||
sig := <-ch
|
||||
logger.Infof(ctx, "handle signal %v, exiting", sig)
|
||||
cancel()
|
||||
}()
|
||||
|
||||
svc, err := service.NewService(ctx)
|
||||
if err != nil {
|
||||
|
Reference in New Issue
Block a user