|
|
@ -100,10 +100,13 @@ func registerObjectStorageShutdown(callback func() errCode) { |
|
|
|
shutdownObjectStorageCallbacks = append(shutdownObjectStorageCallbacks, callback) |
|
|
|
shutdownObjectStorageCallbacks = append(shutdownObjectStorageCallbacks, callback) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Represents a type of an exit func which will be invoked during shutdown signal.
|
|
|
|
|
|
|
|
type onExitFunc func(code int) |
|
|
|
|
|
|
|
|
|
|
|
// Start to monitor shutdownSignal to execute shutdown callbacks
|
|
|
|
// Start to monitor shutdownSignal to execute shutdown callbacks
|
|
|
|
func monitorShutdownSignal() { |
|
|
|
func monitorShutdownSignal(onExitFn onExitFunc) { |
|
|
|
go func() { |
|
|
|
go func() { |
|
|
|
// Monitor processus signal
|
|
|
|
// Monitor signals.
|
|
|
|
trapCh := signalTrap(os.Interrupt, syscall.SIGTERM) |
|
|
|
trapCh := signalTrap(os.Interrupt, syscall.SIGTERM) |
|
|
|
for { |
|
|
|
for { |
|
|
|
select { |
|
|
|
select { |
|
|
@ -115,7 +118,7 @@ func monitorShutdownSignal() { |
|
|
|
for _, callback := range shutdownCallbacks { |
|
|
|
for _, callback := range shutdownCallbacks { |
|
|
|
exitCode := callback() |
|
|
|
exitCode := callback() |
|
|
|
if exitCode != exitSuccess { |
|
|
|
if exitCode != exitSuccess { |
|
|
|
os.Exit(int(exitCode)) |
|
|
|
onExitFn(int(exitCode)) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
@ -123,11 +126,11 @@ func monitorShutdownSignal() { |
|
|
|
for _, callback := range shutdownObjectStorageCallbacks { |
|
|
|
for _, callback := range shutdownObjectStorageCallbacks { |
|
|
|
exitCode := callback() |
|
|
|
exitCode := callback() |
|
|
|
if exitCode != exitSuccess { |
|
|
|
if exitCode != exitSuccess { |
|
|
|
os.Exit(int(exitCode)) |
|
|
|
onExitFn(int(exitCode)) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
os.Exit(int(exitSuccess)) |
|
|
|
onExitFn(int(exitSuccess)) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}() |
|
|
|
}() |
|
|
|