Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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
- Host: GitHub
- URL: https://github.com/rosylilly/martini-graceful
- Owner: rosylilly
- License: mit
- Created: 2014-09-04T18:07:48.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2014-09-04T18:26:43.000Z (over 10 years ago)
- Last Synced: 2024-12-22T13:14:54.808Z (15 days ago)
- Language: Go
- Size: 1.82 MB
- Stars: 2
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.mkd
- License: LICENSE
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 mainimport (
"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 mainimport (
"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)