minio/server-main.go

67 lines
1.7 KiB
Go
Raw Normal View History

/*
* 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 (
"github.com/minio/cli"
"github.com/minio/minio/pkg/server"
"github.com/minio/minio/pkg/server/api"
)
var serverCmd = cli.Command{
Name: "server",
2015-09-18 02:49:06 -04:00
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)
}
2015-09-18 02:49:06 -04:00
2015-09-19 02:32:31 -04:00
apiServerConfig := getServerConfig(c)
2015-09-18 02:49:06 -04:00
err := server.Start(apiServerConfig)
2015-09-19 02:32:31 -04:00
errorIf(err.Trace(), "Failed to start the minio server.", nil)
}