Fix early init. problem for notifications (Fixes #2972) (#2977)

master
Aditya Manthramurthy 8 years ago committed by Harshavardhana
parent f8e13fb00e
commit 0ff359ca0e
  1. 11
      cmd/routers.go
  2. 16
      cmd/server-main.go

@ -45,6 +45,13 @@ func newObjectLayer(storageDisks []StorageAPI) (ObjectLayer, error) {
return nil, err return nil, err
} }
// The following actions are performed here, so that any
// requests coming in early in the bootup sequence don't fail
// unexpectedly - e.g. if initEventNotifier was initialized
// after this function completes, an event could be generated
// before the notification system is ready, causing event
// drops or crashes.
// Migrate bucket policy from configDir to .minio.sys/buckets/ // Migrate bucket policy from configDir to .minio.sys/buckets/
err = migrateBucketPolicyConfig(objAPI) err = migrateBucketPolicyConfig(objAPI)
if err != nil { if err != nil {
@ -62,6 +69,10 @@ func newObjectLayer(storageDisks []StorageAPI) (ObjectLayer, error) {
err = initBucketPolicies(objAPI) err = initBucketPolicies(objAPI)
fatalIf(err, "Unable to load all bucket policies.") fatalIf(err, "Unable to load all bucket policies.")
// Initialize a new event notifier.
err = initEventNotifier(objAPI)
fatalIf(err, "Unable to initialize event notification.")
// Success. // Success.
return objAPI, nil return objAPI, nil
} }

@ -363,6 +363,12 @@ func serverMain(c *cli.Context) {
// Fetch endpoints which we are going to serve from. // Fetch endpoints which we are going to serve from.
endPoints := finalizeEndpoints(tls, &apiServer.Server) endPoints := finalizeEndpoints(tls, &apiServer.Server)
// Initialize local server address
globalMinioAddr = getLocalAddress(srvConfig)
// Initialize S3 Peers inter-node communication
initGlobalS3Peers(disks)
// Start server, automatically configures TLS if certs are available. // Start server, automatically configures TLS if certs are available.
go func(tls bool) { go func(tls bool) {
var lerr error var lerr error
@ -387,16 +393,6 @@ func serverMain(c *cli.Context) {
globalObjectAPI = newObject globalObjectAPI = newObject
globalObjLayerMutex.Unlock() globalObjLayerMutex.Unlock()
// Initialize local server address
globalMinioAddr = getLocalAddress(srvConfig)
// Initialize S3 Peers inter-node communication
initGlobalS3Peers(disks)
// Initialize a new event notifier.
err = initEventNotifier(newObjectLayerFn())
fatalIf(err, "Unable to initialize event notification.")
// Prints the formatted startup message once object layer is initialized. // Prints the formatted startup message once object layer is initialized.
printStartupMessage(endPoints) printStartupMessage(endPoints)

Loading…
Cancel
Save