aboutsummaryrefslogtreecommitdiff
path: root/README.md
diff options
context:
space:
mode:
authorAlexander Kiryukhin <a.kiryukhin@corp.mail.ru>2019-01-11 17:22:06 +0300
committerAlexander Kiryukhin <a.kiryukhin@corp.mail.ru>2019-01-11 17:22:06 +0300
commita4e62510cf1c06831c9c6e4c3a21ff986ebad14c (patch)
tree80ca7af46604e47f4833a4466e9ca9d7e82ad17b /README.md
parentc582001e89c0b81df1b9eb1e8f1857d1c075a805 (diff)
Added OS signals handler
Added go.mod
Diffstat (limited to 'README.md')
-rwxr-xr-xREADME.md15
1 files changed, 3 insertions, 12 deletions
diff --git a/README.md b/README.md
index c7beb77..03236eb 100755
--- a/README.md
+++ b/README.md
@@ -15,7 +15,7 @@ HTTP server with graceful shutdown (`example/http_server.go`):
```
// New instance with builtin context. Alternative: r, ctx := rutina.WithContext(ctx)
-r := rutina.New()
+r, _ := rutina.New()
srv := &http.Server{Addr: ":8080"}
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
@@ -38,17 +38,8 @@ r.Go(func(ctx context.Context) error {
return srv.Shutdown(ctx)
})
-// OS signals subscriber
-r.Go(func(ctx context.Context) error {
- sig := make(chan os.Signal, 1)
- signal.Notify(sig, syscall.SIGTERM, syscall.SIGINT)
- select {
- case <-sig:
- log.Println("TERM or INT signal received")
- case <-ctx.Done():
- }
- return nil
-})
+// OS signals listener
+r.ListenTermSignals()
if err := r.Wait(); err != nil {
log.Fatal(err)