2015-08-20 16:05:47 -04:00
|
|
|
|
/*
|
|
|
|
|
* 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
|
|
|
|
|
|
2015-09-19 05:36:50 -04:00
|
|
|
|
import (
|
|
|
|
|
"crypto/tls"
|
2015-10-16 14:26:01 -04:00
|
|
|
|
"encoding/json"
|
|
|
|
|
"fmt"
|
2015-09-19 05:36:50 -04:00
|
|
|
|
"net"
|
|
|
|
|
"net/http"
|
|
|
|
|
"os"
|
2015-10-16 14:26:01 -04:00
|
|
|
|
"runtime"
|
2015-10-17 22:17:33 -04:00
|
|
|
|
"strconv"
|
2015-09-19 05:36:50 -04:00
|
|
|
|
"strings"
|
2015-10-18 17:47:56 -04:00
|
|
|
|
"time"
|
2015-09-19 05:36:50 -04:00
|
|
|
|
|
2015-10-16 14:26:01 -04:00
|
|
|
|
"github.com/fatih/color"
|
2015-09-19 05:36:50 -04:00
|
|
|
|
"github.com/minio/cli"
|
2015-10-16 14:26:01 -04:00
|
|
|
|
"github.com/minio/minio-xl/pkg/minhttp"
|
|
|
|
|
"github.com/minio/minio-xl/pkg/probe"
|
2015-09-19 05:36:50 -04:00
|
|
|
|
)
|
2015-08-20 16:05:47 -04:00
|
|
|
|
|
|
|
|
|
var serverCmd = cli.Command{
|
|
|
|
|
Name: "server",
|
2015-10-16 14:26:01 -04:00
|
|
|
|
Usage: "Start Minio cloud storage server.",
|
2015-08-20 16:05:47 -04:00
|
|
|
|
Action: serverMain,
|
|
|
|
|
CustomHelpTemplate: `NAME:
|
2015-10-16 14:26:01 -04:00
|
|
|
|
minio {{.Name}} - {{.Usage}}
|
2015-08-20 16:05:47 -04:00
|
|
|
|
|
|
|
|
|
USAGE:
|
2015-10-22 04:31:09 -04:00
|
|
|
|
minio {{.Name}} [OPTION VALUE] PATH
|
|
|
|
|
|
|
|
|
|
OPTION = expiry VALUE = NN[h|m|s] [DEFAULT=Unlimited]
|
|
|
|
|
OPTION = min-free-disk VALUE = NN% [DEFAULT: 10%]
|
2015-08-20 16:05:47 -04:00
|
|
|
|
|
|
|
|
|
EXAMPLES:
|
2015-10-16 14:26:01 -04:00
|
|
|
|
1. Start minio server on Linux.
|
|
|
|
|
$ minio {{.Name}} /home/shared
|
2015-08-20 16:05:47 -04:00
|
|
|
|
|
2015-10-16 14:26:01 -04:00
|
|
|
|
2. Start minio server on Windows.
|
|
|
|
|
$ minio {{.Name}} C:\MyShare
|
|
|
|
|
|
|
|
|
|
3. Start minio server bound to a specific IP:PORT, when you have multiple network interfaces.
|
2015-10-17 22:17:33 -04:00
|
|
|
|
$ minio --address 192.168.1.101:9000 {{.Name}} /home/shared
|
|
|
|
|
|
|
|
|
|
4. Start minio server with minimum free disk threshold to 5%
|
2015-10-19 03:46:03 -04:00
|
|
|
|
$ minio {{.Name}} min-free-disk 5% /home/shared/Pictures
|
2015-10-18 17:47:56 -04:00
|
|
|
|
|
|
|
|
|
5. Start minio server with minimum free disk threshold to 15% with auto expiration set to 1h
|
|
|
|
|
$ minio {{.Name}} min-free-disk 15% expiry 1h /home/shared/Documents
|
|
|
|
|
|
2015-08-20 16:05:47 -04:00
|
|
|
|
`,
|
|
|
|
|
}
|
|
|
|
|
|
2015-10-20 03:33:53 -04:00
|
|
|
|
// cloudServerConfig - http server config
|
|
|
|
|
type cloudServerConfig struct {
|
|
|
|
|
/// HTTP server options
|
2016-01-21 19:28:15 -05:00
|
|
|
|
Address string // Address:Port listening
|
|
|
|
|
WebAddress string // WebAddress:Port listening
|
|
|
|
|
AccessLog bool // Enable access log handler
|
|
|
|
|
Anonymous bool // No signature turn off
|
2015-10-20 03:33:53 -04:00
|
|
|
|
|
2016-01-23 22:44:32 -05:00
|
|
|
|
// Credentials.
|
|
|
|
|
AccessKeyID string // Access key id.
|
|
|
|
|
SecretAccessKey string // Secret access key.
|
|
|
|
|
|
2015-10-20 03:33:53 -04:00
|
|
|
|
/// FS options
|
|
|
|
|
Path string // Path to export for cloud storage
|
|
|
|
|
MinFreeDisk int64 // Minimum free disk space for filesystem
|
|
|
|
|
Expiry time.Duration // Set auto expiry for filesystem
|
|
|
|
|
|
2016-01-17 04:39:09 -05:00
|
|
|
|
/// TLS service
|
2015-10-20 03:33:53 -04:00
|
|
|
|
TLS bool // TLS on when certs are specified
|
|
|
|
|
CertFile string // Domain certificate
|
|
|
|
|
KeyFile string // Domain key
|
|
|
|
|
|
|
|
|
|
/// Advanced HTTP server options
|
|
|
|
|
RateLimit int // Ratelimited server of incoming connections
|
|
|
|
|
}
|
|
|
|
|
|
2016-01-21 19:28:15 -05:00
|
|
|
|
func configureWebServer(conf cloudServerConfig) (*http.Server, *probe.Error) {
|
|
|
|
|
// Minio server config
|
|
|
|
|
webServer := &http.Server{
|
|
|
|
|
Addr: conf.WebAddress,
|
|
|
|
|
Handler: getWebAPIHandler(getNewWebAPI(conf)),
|
|
|
|
|
MaxHeaderBytes: 1 << 20,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if conf.TLS {
|
|
|
|
|
var err error
|
|
|
|
|
webServer.TLSConfig = &tls.Config{}
|
|
|
|
|
webServer.TLSConfig.Certificates = make([]tls.Certificate, 1)
|
|
|
|
|
webServer.TLSConfig.Certificates[0], err = tls.LoadX509KeyPair(conf.CertFile, conf.KeyFile)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, probe.NewError(err)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
host, port, err := net.SplitHostPort(conf.WebAddress)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, probe.NewError(err)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var hosts []string
|
|
|
|
|
switch {
|
|
|
|
|
case host != "":
|
|
|
|
|
hosts = append(hosts, host)
|
|
|
|
|
default:
|
|
|
|
|
addrs, err := net.InterfaceAddrs()
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, probe.NewError(err)
|
|
|
|
|
}
|
|
|
|
|
for _, addr := range addrs {
|
|
|
|
|
if addr.Network() == "ip+net" {
|
|
|
|
|
host := strings.Split(addr.String(), "/")[0]
|
|
|
|
|
if ip := net.ParseIP(host); ip.To4() != nil {
|
|
|
|
|
hosts = append(hosts, host)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Println("Starting minio web server:")
|
|
|
|
|
for _, host := range hosts {
|
|
|
|
|
if conf.TLS {
|
|
|
|
|
Printf("Listening on https://%s:%s\n", host, port)
|
|
|
|
|
} else {
|
|
|
|
|
Printf("Listening on http://%s:%s\n", host, port)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return webServer, nil
|
|
|
|
|
}
|
|
|
|
|
|
2015-09-19 23:52:57 -04:00
|
|
|
|
// configureAPIServer configure a new server instance
|
2015-10-20 03:33:53 -04:00
|
|
|
|
func configureAPIServer(conf cloudServerConfig) (*http.Server, *probe.Error) {
|
2015-09-19 05:36:50 -04:00
|
|
|
|
// Minio server config
|
2015-09-19 23:52:57 -04:00
|
|
|
|
apiServer := &http.Server{
|
2015-09-19 05:36:50 -04:00
|
|
|
|
Addr: conf.Address,
|
2015-10-17 22:17:33 -04:00
|
|
|
|
Handler: getCloudStorageAPIHandler(getNewCloudStorageAPI(conf)),
|
2015-09-19 05:36:50 -04:00
|
|
|
|
MaxHeaderBytes: 1 << 20,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if conf.TLS {
|
|
|
|
|
var err error
|
2015-09-19 23:52:57 -04:00
|
|
|
|
apiServer.TLSConfig = &tls.Config{}
|
|
|
|
|
apiServer.TLSConfig.Certificates = make([]tls.Certificate, 1)
|
|
|
|
|
apiServer.TLSConfig.Certificates[0], err = tls.LoadX509KeyPair(conf.CertFile, conf.KeyFile)
|
2015-09-19 05:36:50 -04:00
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, probe.NewError(err)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
host, port, err := net.SplitHostPort(conf.Address)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, probe.NewError(err)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var hosts []string
|
|
|
|
|
switch {
|
|
|
|
|
case host != "":
|
|
|
|
|
hosts = append(hosts, host)
|
|
|
|
|
default:
|
|
|
|
|
addrs, err := net.InterfaceAddrs()
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, probe.NewError(err)
|
|
|
|
|
}
|
|
|
|
|
for _, addr := range addrs {
|
|
|
|
|
if addr.Network() == "ip+net" {
|
|
|
|
|
host := strings.Split(addr.String(), "/")[0]
|
|
|
|
|
if ip := net.ParseIP(host); ip.To4() != nil {
|
|
|
|
|
hosts = append(hosts, host)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-10-16 14:26:01 -04:00
|
|
|
|
Println("Starting minio server:")
|
2015-09-19 05:36:50 -04:00
|
|
|
|
for _, host := range hosts {
|
|
|
|
|
if conf.TLS {
|
2015-10-16 14:26:01 -04:00
|
|
|
|
Printf("Listening on https://%s:%s\n", host, port)
|
2015-09-19 05:36:50 -04:00
|
|
|
|
} else {
|
2015-10-16 14:26:01 -04:00
|
|
|
|
Printf("Listening on http://%s:%s\n", host, port)
|
2015-09-19 05:36:50 -04:00
|
|
|
|
}
|
2015-09-19 23:52:57 -04:00
|
|
|
|
}
|
|
|
|
|
return apiServer, nil
|
|
|
|
|
}
|
|
|
|
|
|
2015-09-19 05:36:50 -04:00
|
|
|
|
// startServer starts an s3 compatible cloud storage server
|
2015-10-20 03:33:53 -04:00
|
|
|
|
func startServer(conf cloudServerConfig) *probe.Error {
|
2015-10-17 22:17:33 -04:00
|
|
|
|
apiServer, err := configureAPIServer(conf)
|
2015-09-19 05:36:50 -04:00
|
|
|
|
if err != nil {
|
|
|
|
|
return err.Trace()
|
|
|
|
|
}
|
2016-01-21 19:28:15 -05:00
|
|
|
|
webServer, err := configureWebServer(conf)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return err.Trace()
|
|
|
|
|
}
|
2015-10-17 22:17:33 -04:00
|
|
|
|
rateLimit := conf.RateLimit
|
2016-01-21 19:28:15 -05:00
|
|
|
|
if err := minhttp.ListenAndServeLimited(rateLimit, apiServer, webServer); err != nil {
|
2015-09-19 05:36:50 -04:00
|
|
|
|
return err.Trace()
|
|
|
|
|
}
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
2015-10-17 22:17:33 -04:00
|
|
|
|
// parse input string with percent to int64
|
|
|
|
|
func parsePercentToInt(s string, bitSize int) (int64, *probe.Error) {
|
|
|
|
|
i := strings.Index(s, "%")
|
|
|
|
|
if i < 0 {
|
|
|
|
|
// no percentage string found try to parse the whole string anyways
|
|
|
|
|
p, err := strconv.ParseInt(s, 10, bitSize)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return 0, probe.NewError(err)
|
|
|
|
|
}
|
|
|
|
|
return p, nil
|
|
|
|
|
}
|
|
|
|
|
p, err := strconv.ParseInt(s[:i], 10, bitSize)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return 0, probe.NewError(err)
|
|
|
|
|
}
|
|
|
|
|
return p, nil
|
|
|
|
|
}
|
2015-10-21 20:02:40 -04:00
|
|
|
|
func setLogger(conf *configV2) *probe.Error {
|
|
|
|
|
if conf.IsMongoLoggingEnabled() {
|
|
|
|
|
err := log2Mongo(conf.MongoLogger.Addr, conf.MongoLogger.DB, conf.MongoLogger.Collection)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return err.Trace()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if conf.IsSysloggingEnabled() {
|
|
|
|
|
err := log2Syslog(conf.SyslogLogger.Network, conf.SyslogLogger.Addr)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return err.Trace()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if conf.IsFileLoggingEnabled() {
|
|
|
|
|
err := log2File(conf.FileLogger.Filename)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return err.Trace()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return nil
|
|
|
|
|
}
|
2015-10-17 22:17:33 -04:00
|
|
|
|
|
2015-10-21 20:02:40 -04:00
|
|
|
|
// Generates config if it doesn't exist, otherwise returns back the saved ones.
|
|
|
|
|
func getConfig() (*configV2, *probe.Error) {
|
2015-10-20 03:33:53 -04:00
|
|
|
|
if err := createConfigPath(); err != nil {
|
2015-10-16 14:26:01 -04:00
|
|
|
|
return nil, err.Trace()
|
|
|
|
|
}
|
2015-10-20 03:33:53 -04:00
|
|
|
|
config, err := loadConfigV2()
|
2015-10-16 14:26:01 -04:00
|
|
|
|
if err != nil {
|
|
|
|
|
if os.IsNotExist(err.ToGoError()) {
|
|
|
|
|
// Initialize new config, since config file doesn't exist yet
|
2016-01-18 21:45:24 -05:00
|
|
|
|
config = &configV2{}
|
2015-10-20 03:33:53 -04:00
|
|
|
|
config.Version = "2"
|
|
|
|
|
config.Credentials.AccessKeyID = string(mustGenerateAccessKeyID())
|
|
|
|
|
config.Credentials.SecretAccessKey = string(mustGenerateSecretAccessKey())
|
2016-01-17 04:39:09 -05:00
|
|
|
|
config.Credentials.Region = "us-east-1"
|
2016-01-18 21:45:24 -05:00
|
|
|
|
if err = saveConfig(config); err != nil {
|
2015-10-16 14:26:01 -04:00
|
|
|
|
return nil, err.Trace()
|
|
|
|
|
}
|
|
|
|
|
return config, nil
|
|
|
|
|
}
|
|
|
|
|
return nil, err.Trace()
|
|
|
|
|
}
|
|
|
|
|
return config, nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type accessKeys struct {
|
2015-10-20 03:33:53 -04:00
|
|
|
|
*configV2
|
2015-10-16 14:26:01 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (a accessKeys) String() string {
|
|
|
|
|
magenta := color.New(color.FgMagenta, color.Bold).SprintFunc()
|
|
|
|
|
white := color.New(color.FgWhite, color.Bold).SprintfFunc()
|
2015-10-20 03:33:53 -04:00
|
|
|
|
return fmt.Sprint(magenta("AccessKey: ") + white(a.Credentials.AccessKeyID) + " " + magenta("SecretKey: ") + white(a.Credentials.SecretAccessKey))
|
2015-10-16 14:26:01 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// JSON - json formatted output
|
|
|
|
|
func (a accessKeys) JSON() string {
|
|
|
|
|
b, err := json.Marshal(a)
|
|
|
|
|
errorIf(probe.NewError(err), "Unable to marshal json", nil)
|
|
|
|
|
return string(b)
|
|
|
|
|
}
|
|
|
|
|
|
2015-10-21 20:02:40 -04:00
|
|
|
|
// initServer initialize server
|
2016-01-23 22:44:32 -05:00
|
|
|
|
func initServer() (*configV2, *probe.Error) {
|
2015-10-21 20:02:40 -04:00
|
|
|
|
conf, err := getConfig()
|
2015-10-16 14:26:01 -04:00
|
|
|
|
if err != nil {
|
2016-01-23 22:44:32 -05:00
|
|
|
|
return nil, err.Trace()
|
2015-10-16 14:26:01 -04:00
|
|
|
|
}
|
2015-10-21 20:02:40 -04:00
|
|
|
|
if err := setLogger(conf); err != nil {
|
2016-01-23 22:44:32 -05:00
|
|
|
|
return nil, err.Trace()
|
2015-10-21 20:02:40 -04:00
|
|
|
|
}
|
2015-10-16 14:26:01 -04:00
|
|
|
|
if conf != nil {
|
|
|
|
|
Println()
|
2015-12-06 17:31:20 -05:00
|
|
|
|
Println(accessKeys{conf})
|
|
|
|
|
}
|
|
|
|
|
Println("\nTo configure Minio Client.")
|
|
|
|
|
if runtime.GOOS == "windows" {
|
2015-12-13 16:57:47 -05:00
|
|
|
|
Println("\n\tDownload https://dl.minio.io/client/mc/release/" + runtime.GOOS + "-" + runtime.GOARCH + "/mc.exe")
|
2015-12-06 17:31:20 -05:00
|
|
|
|
Println("\t$ mc.exe config host add http://localhost:9000 " + conf.Credentials.AccessKeyID + " " + conf.Credentials.SecretAccessKey)
|
2016-01-13 12:40:20 -05:00
|
|
|
|
Println("\t$ mc.exe mb localhost:9000/photobucket")
|
|
|
|
|
Println("\t$ mc.exe cp --recursive C:\\Photos localhost:9000/photobucket")
|
2015-12-06 17:31:20 -05:00
|
|
|
|
} else {
|
2015-12-13 16:57:47 -05:00
|
|
|
|
Println("\n\t$ wget https://dl.minio.io/client/mc/release/" + runtime.GOOS + "-" + runtime.GOARCH + "/mc")
|
2015-12-06 17:31:20 -05:00
|
|
|
|
Println("\t$ chmod 755 mc")
|
|
|
|
|
Println("\t$ ./mc config host add http://localhost:9000 " + conf.Credentials.AccessKeyID + " " + conf.Credentials.SecretAccessKey)
|
2016-01-13 12:40:20 -05:00
|
|
|
|
Println("\t$ ./mc mb localhost:9000/photobucket")
|
|
|
|
|
Println("\t$ ./mc cp --recursive ~/Photos localhost:9000/photobucket")
|
2015-10-16 14:26:01 -04:00
|
|
|
|
}
|
2015-12-06 17:31:20 -05:00
|
|
|
|
Println()
|
2016-01-23 22:44:32 -05:00
|
|
|
|
return conf, nil
|
2015-10-16 14:26:01 -04:00
|
|
|
|
}
|
|
|
|
|
|
2015-10-19 03:46:03 -04:00
|
|
|
|
func checkServerSyntax(c *cli.Context) {
|
2015-10-16 14:26:01 -04:00
|
|
|
|
if !c.Args().Present() || c.Args().First() == "help" {
|
2015-08-20 16:05:47 -04:00
|
|
|
|
cli.ShowCommandHelpAndExit(c, "server", 1)
|
|
|
|
|
}
|
2015-10-18 17:47:56 -04:00
|
|
|
|
if len(c.Args()) > 5 {
|
2015-10-19 03:46:03 -04:00
|
|
|
|
fatalIf(probe.NewError(errInvalidArgument), "Unnecessary arguments passed. Please refer ‘mc server help’", nil)
|
|
|
|
|
}
|
|
|
|
|
path := strings.TrimSpace(c.Args().Last())
|
|
|
|
|
if path == "" {
|
|
|
|
|
fatalIf(probe.NewError(errInvalidArgument), "Path argument cannot be empty.", nil)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func serverMain(c *cli.Context) {
|
|
|
|
|
checkServerSyntax(c)
|
2015-09-18 02:49:06 -04:00
|
|
|
|
|
2016-01-23 22:44:32 -05:00
|
|
|
|
conf, perr := initServer()
|
2015-10-21 20:02:40 -04:00
|
|
|
|
fatalIf(perr.Trace(), "Failed to read config for minio.", nil)
|
2015-10-16 14:26:01 -04:00
|
|
|
|
|
2015-10-19 03:46:03 -04:00
|
|
|
|
certFile := c.GlobalString("cert")
|
|
|
|
|
keyFile := c.GlobalString("key")
|
|
|
|
|
if (certFile != "" && keyFile == "") || (certFile == "" && keyFile != "") {
|
|
|
|
|
fatalIf(probe.NewError(errInvalidArgument), "Both certificate and key are required to enable https.", nil)
|
|
|
|
|
}
|
2015-10-18 17:47:56 -04:00
|
|
|
|
|
2015-10-19 03:46:03 -04:00
|
|
|
|
var minFreeDisk int64
|
2015-10-18 17:47:56 -04:00
|
|
|
|
minFreeDiskSet := false
|
2015-10-19 13:29:54 -04:00
|
|
|
|
// Default
|
|
|
|
|
minFreeDisk = 10
|
2015-10-18 17:47:56 -04:00
|
|
|
|
|
|
|
|
|
var expiration time.Duration
|
|
|
|
|
expirationSet := false
|
|
|
|
|
|
|
|
|
|
args := c.Args()
|
|
|
|
|
for len(args) >= 2 {
|
|
|
|
|
switch args.First() {
|
|
|
|
|
case "min-free-disk":
|
|
|
|
|
if minFreeDiskSet {
|
|
|
|
|
fatalIf(probe.NewError(errInvalidArgument), "Minimum free disk should be set only once.", nil)
|
|
|
|
|
}
|
|
|
|
|
args = args.Tail()
|
|
|
|
|
var err *probe.Error
|
|
|
|
|
minFreeDisk, err = parsePercentToInt(args.First(), 64)
|
|
|
|
|
fatalIf(err.Trace(args.First()), "Invalid minium free disk size "+args.First()+" passed.", nil)
|
|
|
|
|
args = args.Tail()
|
|
|
|
|
minFreeDiskSet = true
|
|
|
|
|
case "expiry":
|
|
|
|
|
if expirationSet {
|
|
|
|
|
fatalIf(probe.NewError(errInvalidArgument), "Expiration should be set only once.", nil)
|
|
|
|
|
}
|
|
|
|
|
args = args.Tail()
|
|
|
|
|
var err error
|
|
|
|
|
expiration, err = time.ParseDuration(args.First())
|
|
|
|
|
fatalIf(probe.NewError(err), "Invalid expiration time "+args.First()+" passed.", nil)
|
|
|
|
|
args = args.Tail()
|
|
|
|
|
expirationSet = true
|
|
|
|
|
default:
|
|
|
|
|
cli.ShowCommandHelpAndExit(c, "server", 1) // last argument is exit code
|
2015-10-19 03:46:03 -04:00
|
|
|
|
}
|
|
|
|
|
}
|
2015-10-18 17:47:56 -04:00
|
|
|
|
|
|
|
|
|
path := strings.TrimSpace(c.Args().Last())
|
|
|
|
|
// Last argument is always path
|
|
|
|
|
if _, err := os.Stat(path); err != nil {
|
|
|
|
|
fatalIf(probe.NewError(err), "Unable to validate the path", nil)
|
|
|
|
|
}
|
2015-10-19 03:46:03 -04:00
|
|
|
|
tls := (certFile != "" && keyFile != "")
|
2015-10-20 03:33:53 -04:00
|
|
|
|
apiServerConfig := cloudServerConfig{
|
2016-01-23 22:44:32 -05:00
|
|
|
|
Address: c.GlobalString("address"),
|
|
|
|
|
WebAddress: c.GlobalString("web-address"),
|
|
|
|
|
AccessLog: c.GlobalBool("enable-accesslog"),
|
|
|
|
|
Anonymous: c.GlobalBool("anonymous"),
|
|
|
|
|
AccessKeyID: conf.Credentials.AccessKeyID,
|
|
|
|
|
SecretAccessKey: conf.Credentials.SecretAccessKey,
|
|
|
|
|
Path: path,
|
|
|
|
|
MinFreeDisk: minFreeDisk,
|
|
|
|
|
Expiry: expiration,
|
|
|
|
|
TLS: tls,
|
|
|
|
|
CertFile: certFile,
|
|
|
|
|
KeyFile: keyFile,
|
|
|
|
|
RateLimit: c.GlobalInt("ratelimit"),
|
2015-10-19 03:46:03 -04:00
|
|
|
|
}
|
2015-10-18 17:47:56 -04:00
|
|
|
|
perr = startServer(apiServerConfig)
|
|
|
|
|
errorIf(perr.Trace(), "Failed to start the minio server.", nil)
|
2015-08-20 16:05:47 -04:00
|
|
|
|
}
|