Discover Packages
github.com/chapsuk/grace
package
module
Version:
v0.4.1
Opens a new window with list of versions in this module.
Published: Feb 20, 2019
License: MIT
Opens a new window with license information.
Imports: 4
Opens a new window with list of imports.
Imported by: 14
Opens a new window with list of known importers.
README
README
¶
Grace pkg
Package with single function for create base context which will be canceled on signals:
SIGINT, SIGTERM, SIGHUP.
Example
package main
import (
"context"
"github.com/chapsuk/grace"
)
func main() {
ctx := grace.ShutdownContext(context.Background())
<-ctx.Done()
// do graceful shutdown after context was canceled
}
Expand ▾
Collapse ▴
Documentation
¶
ShutdownContext returns child context from passed context which will be canceled
on incoming signals: SIGINT, SIGTERM, SIGHUP.
Ends immediately by os.Exit(1) after second signal
Source Files
¶
Click to show internal directories.
Click to hide internal directories.