You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
minio/server-main.go

71 lines
1.8 KiB

/*
* Minio Cloud Storage, (C) 2015 Minio, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package main
import (
"fmt"
"github.com/minio/cli"
"github.com/minio/minio/pkg/probe"
"github.com/minio/minio/pkg/server"
"github.com/minio/minio/pkg/server/api"
)
var serverCmd = cli.Command{
Name: "server",
Usage: "Start minio server.",
Action: serverMain,
CustomHelpTemplate: `NAME:
minio {{.Name}} - {{.Description}}
USAGE:
minio {{.Name}}
EXAMPLES:
1. Start minio server
$ minio {{.Name}}
`,
}
func getServerConfig(c *cli.Context) api.Config {
certFile := c.GlobalString("cert")
keyFile := c.GlobalString("key")
if (certFile != "" && keyFile == "") || (certFile == "" && keyFile != "") {
Fatalln("Both certificate and key are required to enable https.")
}
tls := (certFile != "" && keyFile != "")
return api.Config{
Address: c.GlobalString("address"),
TLS: tls,
CertFile: certFile,
KeyFile: keyFile,
RateLimit: c.GlobalInt("ratelimit"),
}
}
func serverMain(c *cli.Context) {
if c.Args().Present() {
cli.ShowCommandHelpAndExit(c, "server", 1)
}
apiServerConfig := getServerConfig(c)
err := server.Start(apiServerConfig)
err = probe.NewError(fmt.Errorf("Fake error."))
errorIf(err.Trace(), "Failed to start the server.", nil)
}