From c5776ba6a3d8303650208ee8abc8f63cadf5127a Mon Sep 17 00:00:00 2001 From: Alexander Kiryukhin Date: Thu, 17 Jan 2019 07:54:39 +0300 Subject: Many changes --- example/http_server.go | 21 ++++----------------- 1 file changed, 4 insertions(+), 17 deletions(-) mode change 100644 => 100755 example/http_server.go (limited to 'example') diff --git a/example/http_server.go b/example/http_server.go old mode 100644 new mode 100755 index a8072bb..ef25567 --- a/example/http_server.go +++ b/example/http_server.go @@ -4,19 +4,15 @@ package main import ( "context" + "github.com/neonxp/rutina" "io" "log" "net/http" - "os" - "os/signal" - "syscall" - - "github.com/neonxp/rutina" ) func main() { - // New instance with builtin context. Alternative: r, ctx := rutina.WithContext(ctx) - r, _ := rutina.New() + // New instance with builtin context. Alternative: r, ctx := rutina.OptionContext(ctx) + r, _ := rutina.New(rutina.WithStdLogger()) srv := &http.Server{Addr: ":8080"} http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { @@ -40,16 +36,7 @@ func main() { }) // 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 - }) + r.ListenOsSignals() if err := r.Wait(); err != nil { log.Fatal(err) -- cgit v1.2.3