|
|
@ -46,28 +46,45 @@ const ( |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
func Start(config ServerConfig) { |
|
|
|
func Start(config ServerConfig) { |
|
|
|
|
|
|
|
// maintain a list of input and output channels for communicating with services
|
|
|
|
var ctrlChans []chan<- string |
|
|
|
var ctrlChans []chan<- string |
|
|
|
var statusChans []<-chan error |
|
|
|
var statusChans []<-chan error |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// a pair of control channels, we use these primarily to add to the lists above
|
|
|
|
var ctrlChan chan<- string |
|
|
|
var ctrlChan chan<- string |
|
|
|
var statusChan <-chan error |
|
|
|
var statusChan <-chan error |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// configure web server
|
|
|
|
var storage mstorage.Storage |
|
|
|
var storage mstorage.Storage |
|
|
|
var srv = httpserver.HttpServer{} |
|
|
|
var httpConfig = httpserver.HttpServerConfig{} |
|
|
|
srv.Address = config.Address |
|
|
|
httpConfig.Address = config.Address |
|
|
|
srv.TLS = config.Tls |
|
|
|
httpConfig.TLS = config.Tls |
|
|
|
|
|
|
|
|
|
|
|
if config.CertFile != "" { |
|
|
|
if config.CertFile != "" { |
|
|
|
srv.CertFile = config.CertFile |
|
|
|
httpConfig.CertFile = config.CertFile |
|
|
|
} |
|
|
|
} |
|
|
|
if config.KeyFile != "" { |
|
|
|
if config.KeyFile != "" { |
|
|
|
srv.KeyFile = config.KeyFile |
|
|
|
httpConfig.KeyFile = config.KeyFile |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if config.StorageType == InMemoryStorage { |
|
|
|
// instantiate storage
|
|
|
|
|
|
|
|
// preconditions:
|
|
|
|
|
|
|
|
// - storage type specified
|
|
|
|
|
|
|
|
// - any configuration for storage is populated
|
|
|
|
|
|
|
|
// postconditions:
|
|
|
|
|
|
|
|
// - storage driver is initialized
|
|
|
|
|
|
|
|
// - ctrlChans has channel to communicate to storage
|
|
|
|
|
|
|
|
// - statusChans has channel for messages coming from storage
|
|
|
|
|
|
|
|
switch { |
|
|
|
|
|
|
|
case config.StorageType == InMemoryStorage: |
|
|
|
|
|
|
|
{ |
|
|
|
ctrlChan, statusChan, storage = inmemory.Start() |
|
|
|
ctrlChan, statusChan, storage = inmemory.Start() |
|
|
|
ctrlChans = append(ctrlChans, ctrlChan) |
|
|
|
ctrlChans = append(ctrlChans, ctrlChan) |
|
|
|
statusChans = append(statusChans, statusChan) |
|
|
|
statusChans = append(statusChans, statusChan) |
|
|
|
} else if config.StorageType == FileStorage { |
|
|
|
} |
|
|
|
|
|
|
|
case config.StorageType == FileStorage: |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
// TODO Replace this with a more configurable and robust version
|
|
|
|
currentUser, err := user.Current() |
|
|
|
currentUser, err := user.Current() |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
log.Fatal(err) |
|
|
|
log.Fatal(err) |
|
|
@ -82,11 +99,13 @@ func Start(config ServerConfig) { |
|
|
|
ctrlChan, statusChan, storage = fs.Start(rootPath) |
|
|
|
ctrlChan, statusChan, storage = fs.Start(rootPath) |
|
|
|
ctrlChans = append(ctrlChans, ctrlChan) |
|
|
|
ctrlChans = append(ctrlChans, ctrlChan) |
|
|
|
statusChans = append(statusChans, statusChan) |
|
|
|
statusChans = append(statusChans, statusChan) |
|
|
|
} else { |
|
|
|
} |
|
|
|
|
|
|
|
default: // should never happen
|
|
|
|
|
|
|
|
log.Fatal("No storage driver found") |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
ctrlChan, statusChan = httpserver.Start(minioapi.HttpHandler(storage), srv) |
|
|
|
// start minio api in a web server, pass storage driver into it
|
|
|
|
|
|
|
|
ctrlChan, statusChan, _ = httpserver.Start(minioapi.HttpHandler(storage), httpConfig) |
|
|
|
ctrlChans = append(ctrlChans, ctrlChan) |
|
|
|
ctrlChans = append(ctrlChans, ctrlChan) |
|
|
|
statusChans = append(statusChans, statusChan) |
|
|
|
statusChans = append(statusChans, statusChan) |
|
|
|
|
|
|
|
|
|
|
|