mirror of
https://github.com/pgsty/minio.git
synced 2026-07-19 12:10:24 +03:00
Add a generic registerShutdown function for graceful exit (#2344)
* Add a generic registerShutdown function for graceful exit * Add shutdown callback test case
This commit is contained in:
committed by
Harshavardhana
parent
62c0612eac
commit
d28fb5fe23
@@ -17,11 +17,9 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"sync"
|
||||
"syscall"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -35,17 +33,6 @@ const (
|
||||
bucketMetaPrefix = "buckets"
|
||||
)
|
||||
|
||||
// Register callback functions that needs to be called when process shutsdown.
|
||||
// For now, SIGINT triggers the callbacks, in future controller can trigger
|
||||
// shutdown callbacks.
|
||||
func registerShutdown(callback func()) {
|
||||
go func() {
|
||||
trapCh := signalTrap(os.Interrupt, syscall.SIGTERM)
|
||||
<-trapCh
|
||||
callback()
|
||||
}()
|
||||
}
|
||||
|
||||
// isErrIgnored should we ignore this error?, takes a list of errors which can be ignored.
|
||||
func isErrIgnored(err error, ignoredErrs []error) bool {
|
||||
for _, ignoredErr := range ignoredErrs {
|
||||
|
||||
Reference in New Issue
Block a user