aboutsummaryrefslogtreecommitdiff
path: root/example/http_server.go
diff options
context:
space:
mode:
authorAlexander Kiryukhin <a.kiryukhin@mail.ru>2021-03-18 17:58:00 +0300
committerAlexander Kiryukhin <a.kiryukhin@mail.ru>2021-03-18 17:58:00 +0300
commit14fcf184ae40729e270821115e2ba39c475badb9 (patch)
tree81f6d915e6ed6de5ead922b9bdb1ab1be41a5c01 /example/http_server.go
parentcb67839e3c2acb257d8b67bd28ca3dcea258b66a (diff)
Diffstat (limited to 'example/http_server.go')
-rwxr-xr-xexample/http_server.go9
1 files changed, 5 insertions, 4 deletions
diff --git a/example/http_server.go b/example/http_server.go
index 6bb7157..8b723b9 100755
--- a/example/http_server.go
+++ b/example/http_server.go
@@ -7,13 +7,14 @@ import (
"io"
"log"
"net/http"
+ "os"
- "github.com/neonxp/rutina"
+ "github.com/neonxp/rutina/v3"
)
func main() {
// New instance with builtin context
- r := rutina.New(rutina.Opt.SetListenOsSignals(true))
+ r := rutina.New(rutina.ListenOsSignals(os.Interrupt, os.Kill))
srv := &http.Server{Addr: ":8080"}
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
@@ -27,14 +28,14 @@ func main() {
}
log.Println("Server stopped")
return nil
- }, rutina.RunOpt.SetOnDone(rutina.Shutdown))
+ })
// Gracefully stopping server when context canceled
r.Go(func(ctx context.Context) error {
<-ctx.Done()
log.Println("Stopping server...")
return srv.Shutdown(ctx)
- }, nil)
+ })
if err := r.Wait(); err != nil {
log.Fatal(err)