Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/rosylilly/martini-graceful

graceful shutdown for martini
https://github.com/rosylilly/martini-graceful

Last synced: 5 days ago
JSON representation

graceful shutdown for martini

Awesome Lists containing this project

README

        

# Graceful

[![wercker status](https://app.wercker.com/status/9b892bd85ba1b762b3f8d087e918f68b/s/master "wercker status")](https://app.wercker.com/project/bykey/9b892bd85ba1b762b3f8d087e918f68b)

graceful shutdown for martini

[API References](http://godoc.org/github.com/rosylilly/martini-graceful)

## Usage

This package provides graceful shutdown to the martini application.

```go
package main

import (
"github.com/go-martini/martini"
"github.com/rosylilly/martini-graceful"
"log"
"syscall"
"time"
)

func main() {
m := martini.Classic()

gs := graceful.New(10 * time.Second, syscall.SIGTERM, syscall.SIGINT)
m.Use(gs.Handler)

m.Get("/", func() string {
time.Sleep(5 * time.Second)
return "hello world\n"
})

err := gs.RunGracefully(m)
if err != nil {
log.Println(err)
}
}
```

Or:

```go
package main

import (
"github.com/go-martini/martini"
"github.com/rosylilly/martini-graceful"
"log"
"syscall"
"time"
)

func main() {
m := martini.Classic()

gs := graceful.New(10 * time.Second, syscall.SIGTERM, syscall.SIGINT)
m.Use(gs.Handler)

m.Get("/", func() string {
time.Sleep(5 * time.Second)
return "hello world\n"
})

go func() {
m.RunOnAddr(":8080")
}()

err := gs.Wait()
if err != nil {
log.Println(err)
}
}
```

## License

MIT Lisence

## Authors

- [Sho Kusano / @rosylilly](https://github.com/rosylilly)