mirror of
https://github.com/pgsty/minio.git
synced 2026-08-09 07:43:29 +03:00
Protect shutdown callbacks lists with a mutex (#2432)
This commit is contained in:
committed by
Harshavardhana
parent
9606cb9bcd
commit
5526ac13d2
+15
@@ -42,6 +42,9 @@ func newObjectLayer(disks, ignoredDisks []string) (ObjectLayer, error) {
|
||||
|
||||
// configureServer handler returns final handler for the http server.
|
||||
func configureServerHandler(srvCmdConfig serverCmdConfig) http.Handler {
|
||||
// Initialize name space lock.
|
||||
initNSLock()
|
||||
|
||||
objAPI, err := newObjectLayer(srvCmdConfig.disks, srvCmdConfig.ignoredDisks)
|
||||
fatalIf(err, "Unable to intialize object layer.")
|
||||
|
||||
@@ -66,6 +69,18 @@ func configureServerHandler(srvCmdConfig serverCmdConfig) http.Handler {
|
||||
ObjectAPI: objAPI,
|
||||
}
|
||||
|
||||
// Initialize and monitor shutdown signals.
|
||||
err = initGracefulShutdown(os.Exit)
|
||||
fatalIf(err, "Unable to initialize graceful shutdown operation")
|
||||
|
||||
// Register the callback that should be called when the process shuts down.
|
||||
globalShutdownCBs.AddObjectLayerCB(func() errCode {
|
||||
if sErr := objAPI.Shutdown(); sErr != nil {
|
||||
return exitFailure
|
||||
}
|
||||
return exitSuccess
|
||||
})
|
||||
|
||||
// Initialize a new event notifier.
|
||||
err = initEventNotifier(objAPI)
|
||||
fatalIf(err, "Unable to initialize event notification queue")
|
||||
|
||||
Reference in New Issue
Block a user