diff --git a/Godeps/Godeps.json b/Godeps/Godeps.json index 090549db5..62065a55d 100644 --- a/Godeps/Godeps.json +++ b/Godeps/Godeps.json @@ -27,8 +27,8 @@ }, { "ImportPath": "github.com/minio-io/cli", - "Comment": "1.2.0-108-g4ad376c", - "Rev": "4ad376c97a51a452e36aaa4c19e42560e64be836" + "Comment": "1.2.0-110-g111d644", + "Rev": "111d6445d384505978aaf5b218ce96d163b73c57" }, { "ImportPath": "github.com/stretchr/objx", diff --git a/Godeps/_workspace/src/github.com/minio-io/cli/context.go b/Godeps/_workspace/src/github.com/minio-io/cli/context.go index 5b97b8860..cf04dbfe7 100644 --- a/Godeps/_workspace/src/github.com/minio-io/cli/context.go +++ b/Godeps/_workspace/src/github.com/minio-io/cli/context.go @@ -186,7 +186,7 @@ func (a Args) Last() string { // Tail - Return the rest of the arguments (not the first one) // or else an empty string slice -func (a Args) Tail() []string { +func (a Args) Tail() Args { if len(a) >= 2 { return []string(a)[1:] } diff --git a/main.go b/main.go index 37b2abc5b..ad33369b3 100644 --- a/main.go +++ b/main.go @@ -141,11 +141,22 @@ func runMemory(c *cli.Context) { apiServerConfig := getAPIServerConfig(c) maxMemory, err := humanize.ParseBytes(c.Args().First()) if err != nil { - Fatalf("Invalid memory size [%s] passed. Reason: %s\n", c.Args().First(), err) + Fatalf("Invalid memory size [%s] passed. Reason: %s\n", c.Args().First(), iodine.New(err, nil)) + } + tail := c.Args().Tail() + var expiration time.Duration + if tail.First() != "" { + expiration, err = time.ParseDuration(tail.First()) + if err != nil { + Fatalf("Invalid expiration time [%s] passed. Reason: %s\n", tail.First(), iodine.New(err, nil)) + } + } else { + expiration = 0 } memoryDriver := server.MemoryFactory{ - Config: apiServerConfig, - MaxMemory: maxMemory, + Config: apiServerConfig, + MaxMemory: maxMemory, + Expiration: expiration, } apiServer := memoryDriver.GetStartServerFunc() webServer := getWebServerConfigFunc(c) diff --git a/pkg/server/server.go b/pkg/server/server.go index 008360ec6..6f76e3774 100644 --- a/pkg/server/server.go +++ b/pkg/server/server.go @@ -34,13 +34,14 @@ import ( // MemoryFactory is used to build memory api servers type MemoryFactory struct { httpserver.Config - MaxMemory uint64 + MaxMemory uint64 + Expiration time.Duration } // GetStartServerFunc builds memory api servers func (f MemoryFactory) GetStartServerFunc() StartServerFunc { return func() (chan<- string, <-chan error) { - _, _, driver := memory.Start(f.MaxMemory, 1*time.Hour) + _, _, driver := memory.Start(f.MaxMemory, f.Expiration) //ctrl, status, _ := httpserver.Start(api.HTTPHandler(f.Domain, driver), f.Config) ctrl, status, _ := httpserver.Start(api.HTTPHandler("", driver), f.Config) return ctrl, status