Skip to content

Commit

Permalink
update example
Browse files Browse the repository at this point in the history
  • Loading branch information
liujianping committed Sep 29, 2020
1 parent 6402727 commit 6801f4d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
13 changes: 11 additions & 2 deletions example/server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,20 @@ func main() {
// )),
)
log.Println("tcpserver serving ...")
ctx, cancel := context.WithCancel(context.TODO())
defer cancel()
if err := routine.Main(
context.TODO(),
routine.ExecutorFunc(srv.Serve),
ctx,
routine.ExecutorFunc(func(ctx context.Context) error {
<-srv.Serving()
log.Println("serving ... now")
<-ctx.Done()
return nil
}),
routine.Go(routine.ExecutorFunc(srv.Serve)),
routine.Go(routine.Profiling("127.0.0.1:6060")),
routine.Signal(syscall.SIGINT, routine.SigHandler(func() {
cancel()
<-srv.Close()
})),
); err != nil {
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ go 1.14
require (
github.com/x-mod/event v0.0.2
github.com/x-mod/glog v0.1.1
github.com/x-mod/routine v1.3.0 // indirect
github.com/x-mod/routine v1.3.0
golang.org/x/net v0.0.0-20200923182212-328152dc79b1
)

0 comments on commit 6801f4d

Please sign in to comment.