mirror of
https://github.com/minio/minio.git
synced 2025-01-12 15:33:22 -05:00
Improve code further - this time further simplification of names
This commit is contained in:
parent
2721bef8da
commit
674631f9d8
@ -17,6 +17,7 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"crypto/tls"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
@ -45,15 +46,34 @@ EXAMPLES:
|
|||||||
`,
|
`,
|
||||||
}
|
}
|
||||||
|
|
||||||
// getRPCServer instance
|
// configureControllerRPC instance
|
||||||
func getRPCServer(rpcHandler http.Handler) (*http.Server, *probe.Error) {
|
func configureControllerRPC(conf minioConfig, rpcHandler http.Handler) (*http.Server, *probe.Error) {
|
||||||
// Minio server config
|
// Minio server config
|
||||||
httpServer := &http.Server{
|
rpcServer := &http.Server{
|
||||||
Addr: ":9001", // TODO make this configurable
|
Addr: conf.ControllerAddress,
|
||||||
Handler: rpcHandler,
|
Handler: rpcHandler,
|
||||||
MaxHeaderBytes: 1 << 20,
|
MaxHeaderBytes: 1 << 20,
|
||||||
}
|
}
|
||||||
|
if conf.TLS {
|
||||||
|
var err error
|
||||||
|
rpcServer.TLSConfig = &tls.Config{}
|
||||||
|
rpcServer.TLSConfig.Certificates = make([]tls.Certificate, 1)
|
||||||
|
rpcServer.TLSConfig.Certificates[0], err = tls.LoadX509KeyPair(conf.CertFile, conf.KeyFile)
|
||||||
|
if err != nil {
|
||||||
|
return nil, probe.NewError(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
host, port, err := net.SplitHostPort(conf.ControllerAddress)
|
||||||
|
if err != nil {
|
||||||
|
return nil, probe.NewError(err)
|
||||||
|
}
|
||||||
|
|
||||||
var hosts []string
|
var hosts []string
|
||||||
|
switch {
|
||||||
|
case host != "":
|
||||||
|
hosts = append(hosts, host)
|
||||||
|
default:
|
||||||
addrs, err := net.InterfaceAddrs()
|
addrs, err := net.InterfaceAddrs()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, probe.NewError(err)
|
return nil, probe.NewError(err)
|
||||||
@ -66,15 +86,21 @@ func getRPCServer(rpcHandler http.Handler) (*http.Server, *probe.Error) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for _, host := range hosts {
|
|
||||||
fmt.Printf("Starting minio server on: http://%s:9001/rpc, PID: %d\n", host, os.Getpid())
|
|
||||||
}
|
}
|
||||||
return httpServer, nil
|
|
||||||
|
for _, host := range hosts {
|
||||||
|
if conf.TLS {
|
||||||
|
fmt.Printf("Starting minio controller on: https://%s:%s, PID: %d\n", host, port, os.Getpid())
|
||||||
|
} else {
|
||||||
|
fmt.Printf("Starting minio controller on: http://%s:%s, PID: %d\n", host, port, os.Getpid())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return rpcServer, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// startController starts a minio controller
|
// startController starts a minio controller
|
||||||
func startController() *probe.Error {
|
func startController(conf minioConfig) *probe.Error {
|
||||||
rpcServer, err := getRPCServer(getRPCHandler())
|
rpcServer, err := configureControllerRPC(conf, getControllerRPCHandler())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err.Trace()
|
return err.Trace()
|
||||||
}
|
}
|
||||||
@ -85,11 +111,27 @@ func startController() *probe.Error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func getControllerConfig(c *cli.Context) minioConfig {
|
||||||
|
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 minioConfig{
|
||||||
|
ControllerAddress: c.GlobalString("address-controller"),
|
||||||
|
TLS: tls,
|
||||||
|
CertFile: certFile,
|
||||||
|
KeyFile: keyFile,
|
||||||
|
RateLimit: c.GlobalInt("ratelimit"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func controllerMain(c *cli.Context) {
|
func controllerMain(c *cli.Context) {
|
||||||
if c.Args().Present() {
|
if c.Args().Present() {
|
||||||
cli.ShowCommandHelpAndExit(c, "controller", 1)
|
cli.ShowCommandHelpAndExit(c, "controller", 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
err := startController()
|
err := startController(getControllerConfig(c))
|
||||||
errorIf(err.Trace(), "Failed to start minio controller.", nil)
|
errorIf(err.Trace(), "Failed to start minio controller.", nil)
|
||||||
}
|
}
|
||||||
|
@ -24,14 +24,13 @@ import (
|
|||||||
"github.com/gorilla/rpc/v2/json"
|
"github.com/gorilla/rpc/v2/json"
|
||||||
)
|
)
|
||||||
|
|
||||||
// getRPCHandler rpc handler
|
// getControllerRPCHandler rpc handler for controller
|
||||||
func getRPCCtrlHandler() http.Handler {
|
func getControllerRPCHandler() http.Handler {
|
||||||
s := jsonrpc.NewServer()
|
s := jsonrpc.NewServer()
|
||||||
s.RegisterCodec(json.NewCodec(), "application/json")
|
s.RegisterCodec(json.NewCodec(), "application/json")
|
||||||
s.RegisterService(new(VersionService), "Version")
|
|
||||||
s.RegisterService(new(DonutService), "Donut")
|
s.RegisterService(new(DonutService), "Donut")
|
||||||
s.RegisterService(new(AuthService), "Auth")
|
s.RegisterService(new(AuthService), "Auth")
|
||||||
s.RegisterService(new(controllerServerRPCService), "Server")
|
s.RegisterService(new(controllerRPCService), "Server")
|
||||||
// Add new RPC services here
|
// Add new RPC services here
|
||||||
return registerRPC(router.NewRouter(), s)
|
return registerRPC(router.NewRouter(), s)
|
||||||
}
|
}
|
||||||
|
@ -23,17 +23,18 @@ import (
|
|||||||
"github.com/minio/minio/pkg/probe"
|
"github.com/minio/minio/pkg/probe"
|
||||||
)
|
)
|
||||||
|
|
||||||
type controllerServerRPCService struct {
|
type controllerRPCService struct {
|
||||||
serverList []ServerArg
|
serverList []ServerArg
|
||||||
}
|
}
|
||||||
|
|
||||||
func proxyRequest(method string, ip string, arg interface{}, res interface{}) error {
|
func proxyRequest(method string, url string, arg interface{}, res interface{}) error {
|
||||||
|
// can be configured to something else in future
|
||||||
|
namespace := "Server"
|
||||||
op := rpcOperation{
|
op := rpcOperation{
|
||||||
Method: "Server." + method,
|
Method: namespace + "." + method,
|
||||||
Request: arg,
|
Request: arg,
|
||||||
}
|
}
|
||||||
|
request, _ := newRPCRequest(url, op, nil)
|
||||||
request, _ := newRPCRequest("http://"+ip+":9002/rpc", op, nil)
|
|
||||||
resp, err := request.Do()
|
resp, err := request.Do()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return probe.WrapError(err)
|
return probe.WrapError(err)
|
||||||
@ -42,27 +43,31 @@ func proxyRequest(method string, ip string, arg interface{}, res interface{}) er
|
|||||||
return decodeerr
|
return decodeerr
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *controllerServerRPCService) Add(r *http.Request, arg *ServerArg, res *DefaultRep) error {
|
func (s *controllerRPCService) Add(r *http.Request, arg *ServerArg, res *DefaultRep) error {
|
||||||
err := proxyRequest("Add", arg.IP, arg, res)
|
err := proxyRequest("Add", arg.URL, arg, res)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
s.serverList = append(s.serverList, *arg)
|
s.serverList = append(s.serverList, *arg)
|
||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *controllerServerRPCService) MemStats(r *http.Request, arg *ServerArg, res *MemStatsRep) error {
|
func (s *controllerRPCService) MemStats(r *http.Request, arg *ServerArg, res *MemStatsRep) error {
|
||||||
return proxyRequest("MemStats", arg.IP, arg, res)
|
return proxyRequest("MemStats", arg.URL, arg, res)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *controllerServerRPCService) DiskStats(r *http.Request, arg *ServerArg, res *DiskStatsRep) error {
|
func (s *controllerRPCService) DiskStats(r *http.Request, arg *ServerArg, res *DiskStatsRep) error {
|
||||||
return proxyRequest("DiskStats", arg.IP, arg, res)
|
return proxyRequest("DiskStats", arg.URL, arg, res)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *controllerServerRPCService) SysInfo(r *http.Request, arg *ServerArg, res *SysInfoRep) error {
|
func (s *controllerRPCService) SysInfo(r *http.Request, arg *ServerArg, res *SysInfoRep) error {
|
||||||
return proxyRequest("SysInfo", arg.IP, arg, res)
|
return proxyRequest("SysInfo", arg.URL, arg, res)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *controllerServerRPCService) List(r *http.Request, arg *ServerArg, res *ListRep) error {
|
func (s *controllerRPCService) List(r *http.Request, arg *ServerArg, res *ListRep) error {
|
||||||
res.List = s.serverList
|
res.List = s.serverList
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *controllerRPCService) Version(r *http.Request, arg *ServerArg, res *VersionRep) error {
|
||||||
|
return proxyRequest("Version", arg.URL, arg, res)
|
||||||
|
}
|
||||||
|
@ -1,45 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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 (
|
|
||||||
"net/http"
|
|
||||||
"runtime"
|
|
||||||
)
|
|
||||||
|
|
||||||
// VersionArgs basic json RPC params
|
|
||||||
type VersionArgs struct{}
|
|
||||||
|
|
||||||
// VersionService get version service
|
|
||||||
type VersionService struct{}
|
|
||||||
|
|
||||||
// VersionReply version reply
|
|
||||||
type VersionReply struct {
|
|
||||||
Version string `json:"version"`
|
|
||||||
BuildDate string `json:"buildDate"`
|
|
||||||
Architecture string `json:"arch"`
|
|
||||||
OperatingSystem string `json:"os"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get version
|
|
||||||
func (v *VersionService) Get(r *http.Request, args *VersionArgs, reply *VersionReply) error {
|
|
||||||
reply.Version = "0.0.1"
|
|
||||||
reply.BuildDate = minioVersion
|
|
||||||
reply.Architecture = runtime.GOARCH
|
|
||||||
reply.OperatingSystem = runtime.GOOS
|
|
||||||
return nil
|
|
||||||
}
|
|
@ -1,5 +1,3 @@
|
|||||||
// +build ignore
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Minio Cloud Storage, (C) 2014 Minio, Inc.
|
* Minio Cloud Storage, (C) 2014 Minio, Inc.
|
||||||
*
|
*
|
||||||
@ -33,26 +31,33 @@ type ControllerRPCSuite struct{}
|
|||||||
|
|
||||||
var _ = Suite(&ControllerRPCSuite{})
|
var _ = Suite(&ControllerRPCSuite{})
|
||||||
|
|
||||||
var testRPCServer *httptest.Server
|
var (
|
||||||
|
testControllerRPC *httptest.Server
|
||||||
|
testServerRPC *httptest.Server
|
||||||
|
)
|
||||||
|
|
||||||
func (s *ControllerRPCSuite) SetUpSuite(c *C) {
|
func (s *ControllerRPCSuite) SetUpSuite(c *C) {
|
||||||
root, err := ioutil.TempDir(os.TempDir(), "api-")
|
root, err := ioutil.TempDir(os.TempDir(), "api-")
|
||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
auth.SetAuthConfigPath(root)
|
auth.SetAuthConfigPath(root)
|
||||||
|
|
||||||
testRPCServer = httptest.NewServer(getRPCCtrlHandler())
|
testControllerRPC = httptest.NewServer(getControllerRPCHandler())
|
||||||
|
testServerRPC = httptest.NewUnstartedServer(getServerRPCHandler())
|
||||||
|
testServerRPC.Config.Addr = ":9002"
|
||||||
|
testServerRPC.Start()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *ControllerRPCSuite) TearDownSuite(c *C) {
|
func (s *ControllerRPCSuite) TearDownSuite(c *C) {
|
||||||
testRPCServer.Close()
|
testServerRPC.Close()
|
||||||
|
testControllerRPC.Close()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *ControllerRPCSuite) TestMemStats(c *C) {
|
func (s *ControllerRPCSuite) TestMemStats(c *C) {
|
||||||
op := rpcOperation{
|
op := rpcOperation{
|
||||||
Method: "Server.MemStats",
|
Method: "Server.MemStats",
|
||||||
Request: ServerArg{},
|
Request: ServerArg{URL: testServerRPC.URL + "/rpc"},
|
||||||
}
|
}
|
||||||
req, err := newRPCRequest(testRPCServer.URL+"/rpc", op, http.DefaultTransport)
|
req, err := newRPCRequest(testControllerRPC.URL+"/rpc", op, http.DefaultTransport)
|
||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
c.Assert(req.Get("Content-Type"), Equals, "application/json")
|
c.Assert(req.Get("Content-Type"), Equals, "application/json")
|
||||||
resp, err := req.Do()
|
resp, err := req.Do()
|
||||||
@ -68,9 +73,9 @@ func (s *ControllerRPCSuite) TestMemStats(c *C) {
|
|||||||
func (s *ControllerRPCSuite) TestSysInfo(c *C) {
|
func (s *ControllerRPCSuite) TestSysInfo(c *C) {
|
||||||
op := rpcOperation{
|
op := rpcOperation{
|
||||||
Method: "Server.SysInfo",
|
Method: "Server.SysInfo",
|
||||||
Request: ServerArg{},
|
Request: ServerArg{URL: testServerRPC.URL + "/rpc"},
|
||||||
}
|
}
|
||||||
req, err := newRPCRequest(testRPCServer.URL+"/rpc", op, http.DefaultTransport)
|
req, err := newRPCRequest(testControllerRPC.URL+"/rpc", op, http.DefaultTransport)
|
||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
c.Assert(req.Get("Content-Type"), Equals, "application/json")
|
c.Assert(req.Get("Content-Type"), Equals, "application/json")
|
||||||
resp, err := req.Do()
|
resp, err := req.Do()
|
||||||
@ -86,9 +91,9 @@ func (s *ControllerRPCSuite) TestSysInfo(c *C) {
|
|||||||
func (s *ControllerRPCSuite) TestServerList(c *C) {
|
func (s *ControllerRPCSuite) TestServerList(c *C) {
|
||||||
op := rpcOperation{
|
op := rpcOperation{
|
||||||
Method: "Server.List",
|
Method: "Server.List",
|
||||||
Request: ServerArg{},
|
Request: ServerArg{URL: testServerRPC.URL + "/rpc"},
|
||||||
}
|
}
|
||||||
req, err := newRPCRequest(testRPCServer.URL+"/rpc", op, http.DefaultTransport)
|
req, err := newRPCRequest(testControllerRPC.URL+"/rpc", op, http.DefaultTransport)
|
||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
c.Assert(req.Get("Content-Type"), Equals, "application/json")
|
c.Assert(req.Get("Content-Type"), Equals, "application/json")
|
||||||
resp, err := req.Do()
|
resp, err := req.Do()
|
||||||
@ -104,9 +109,9 @@ func (s *ControllerRPCSuite) TestServerList(c *C) {
|
|||||||
func (s *ControllerRPCSuite) TestServerAdd(c *C) {
|
func (s *ControllerRPCSuite) TestServerAdd(c *C) {
|
||||||
op := rpcOperation{
|
op := rpcOperation{
|
||||||
Method: "Server.Add",
|
Method: "Server.Add",
|
||||||
Request: ServerArg{},
|
Request: ServerArg{URL: testServerRPC.URL + "/rpc"},
|
||||||
}
|
}
|
||||||
req, err := newRPCRequest(testRPCServer.URL+"/rpc", op, http.DefaultTransport)
|
req, err := newRPCRequest(testControllerRPC.URL+"/rpc", op, http.DefaultTransport)
|
||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
c.Assert(req.Get("Content-Type"), Equals, "application/json")
|
c.Assert(req.Get("Content-Type"), Equals, "application/json")
|
||||||
resp, err := req.Do()
|
resp, err := req.Do()
|
||||||
@ -124,7 +129,7 @@ func (s *ControllerRPCSuite) TestAuth(c *C) {
|
|||||||
Method: "Auth.Generate",
|
Method: "Auth.Generate",
|
||||||
Request: AuthArgs{User: "newuser"},
|
Request: AuthArgs{User: "newuser"},
|
||||||
}
|
}
|
||||||
req, err := newRPCRequest(testRPCServer.URL+"/rpc", op, http.DefaultTransport)
|
req, err := newRPCRequest(testControllerRPC.URL+"/rpc", op, http.DefaultTransport)
|
||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
c.Assert(req.Get("Content-Type"), Equals, "application/json")
|
c.Assert(req.Get("Content-Type"), Equals, "application/json")
|
||||||
resp, err := req.Do()
|
resp, err := req.Do()
|
||||||
@ -143,7 +148,7 @@ func (s *ControllerRPCSuite) TestAuth(c *C) {
|
|||||||
Method: "Auth.Fetch",
|
Method: "Auth.Fetch",
|
||||||
Request: AuthArgs{User: "newuser"},
|
Request: AuthArgs{User: "newuser"},
|
||||||
}
|
}
|
||||||
req, err = newRPCRequest(testRPCServer.URL+"/rpc", op, http.DefaultTransport)
|
req, err = newRPCRequest(testControllerRPC.URL+"/rpc", op, http.DefaultTransport)
|
||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
c.Assert(req.Get("Content-Type"), Equals, "application/json")
|
c.Assert(req.Get("Content-Type"), Equals, "application/json")
|
||||||
resp, err = req.Do()
|
resp, err = req.Do()
|
||||||
@ -162,7 +167,7 @@ func (s *ControllerRPCSuite) TestAuth(c *C) {
|
|||||||
Method: "Auth.Reset",
|
Method: "Auth.Reset",
|
||||||
Request: AuthArgs{User: "newuser"},
|
Request: AuthArgs{User: "newuser"},
|
||||||
}
|
}
|
||||||
req, err = newRPCRequest(testRPCServer.URL+"/rpc", op, http.DefaultTransport)
|
req, err = newRPCRequest(testControllerRPC.URL+"/rpc", op, http.DefaultTransport)
|
||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
c.Assert(req.Get("Content-Type"), Equals, "application/json")
|
c.Assert(req.Get("Content-Type"), Equals, "application/json")
|
||||||
resp, err = req.Do()
|
resp, err = req.Do()
|
||||||
@ -184,7 +189,7 @@ func (s *ControllerRPCSuite) TestAuth(c *C) {
|
|||||||
Method: "Auth.Generate",
|
Method: "Auth.Generate",
|
||||||
Request: AuthArgs{User: "newuser"},
|
Request: AuthArgs{User: "newuser"},
|
||||||
}
|
}
|
||||||
req, err = newRPCRequest(testRPCServer.URL+"/rpc", op, http.DefaultTransport)
|
req, err = newRPCRequest(testControllerRPC.URL+"/rpc", op, http.DefaultTransport)
|
||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
c.Assert(req.Get("Content-Type"), Equals, "application/json")
|
c.Assert(req.Get("Content-Type"), Equals, "application/json")
|
||||||
resp, err = req.Do()
|
resp, err = req.Do()
|
||||||
@ -196,7 +201,7 @@ func (s *ControllerRPCSuite) TestAuth(c *C) {
|
|||||||
Method: "Auth.Generate",
|
Method: "Auth.Generate",
|
||||||
Request: AuthArgs{User: ""},
|
Request: AuthArgs{User: ""},
|
||||||
}
|
}
|
||||||
req, err = newRPCRequest(testRPCServer.URL+"/rpc", op, http.DefaultTransport)
|
req, err = newRPCRequest(testControllerRPC.URL+"/rpc", op, http.DefaultTransport)
|
||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
c.Assert(req.Get("Content-Type"), Equals, "application/json")
|
c.Assert(req.Get("Content-Type"), Equals, "application/json")
|
||||||
resp, err = req.Do()
|
resp, err = req.Do()
|
||||||
|
8
flags.go
8
flags.go
@ -28,15 +28,15 @@ var (
|
|||||||
Usage: "ADDRESS:PORT for cloud storage access",
|
Usage: "ADDRESS:PORT for cloud storage access",
|
||||||
}
|
}
|
||||||
|
|
||||||
addressMgmtFlag = cli.StringFlag{
|
addressControllerFlag = cli.StringFlag{
|
||||||
Name: "address-mgmt",
|
Name: "address-controller",
|
||||||
Hide: true,
|
Hide: true,
|
||||||
Value: ":9001",
|
Value: ":9001",
|
||||||
Usage: "ADDRESS:PORT for management console access",
|
Usage: "ADDRESS:PORT for management console access",
|
||||||
}
|
}
|
||||||
|
|
||||||
addressRPCServerFlag = cli.StringFlag{
|
addressServerRPCFlag = cli.StringFlag{
|
||||||
Name: "address-rpcserver",
|
Name: "address-server-rpc",
|
||||||
Hide: true,
|
Hide: true,
|
||||||
Value: ":9002",
|
Value: ":9002",
|
||||||
Usage: "ADDRESS:PORT for management console access",
|
Usage: "ADDRESS:PORT for management console access",
|
||||||
|
15
main.go
15
main.go
@ -27,6 +27,17 @@ import (
|
|||||||
"github.com/minio/cli"
|
"github.com/minio/cli"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// minioConfig - http server config
|
||||||
|
type minioConfig struct {
|
||||||
|
Address string
|
||||||
|
ControllerAddress string
|
||||||
|
RPCAddress string
|
||||||
|
TLS bool
|
||||||
|
CertFile string
|
||||||
|
KeyFile string
|
||||||
|
RateLimit int
|
||||||
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
// Check for the environment early on and gracefuly report.
|
// Check for the environment early on and gracefuly report.
|
||||||
|
|
||||||
@ -86,12 +97,12 @@ func registerApp() *cli.App {
|
|||||||
|
|
||||||
// register all flags
|
// register all flags
|
||||||
registerFlag(addressFlag)
|
registerFlag(addressFlag)
|
||||||
registerFlag(addressMgmtFlag)
|
registerFlag(addressControllerFlag)
|
||||||
registerFlag(ratelimitFlag)
|
registerFlag(ratelimitFlag)
|
||||||
registerFlag(certFlag)
|
registerFlag(certFlag)
|
||||||
registerFlag(keyFlag)
|
registerFlag(keyFlag)
|
||||||
registerFlag(debugFlag)
|
registerFlag(debugFlag)
|
||||||
registerFlag(addressRPCServerFlag)
|
registerFlag(addressServerRPCFlag)
|
||||||
|
|
||||||
// set up app
|
// set up app
|
||||||
app := cli.NewApp()
|
app := cli.NewApp()
|
||||||
|
@ -16,65 +16,73 @@
|
|||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
// Ethernet interface
|
// Network properties of a server
|
||||||
type Ifc struct {
|
type Network struct {
|
||||||
IP string `json:"ip"`
|
IP string `json:"address"`
|
||||||
Mask string `json:"mask"`
|
Mask string `json:"netmask"`
|
||||||
Eth string `json:"ifc"`
|
Ethernet string `json:"networkInterface"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Identify a server
|
// ServerArg server metadata to identify a server
|
||||||
type ServerArg struct {
|
type ServerArg struct {
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
IP string `json:"ip"`
|
URL string `json:"url"`
|
||||||
ID string `json:"id"`
|
ID string `json:"id"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Needed for Reply for Server.List
|
// ServerRep server reply container for Server.List
|
||||||
type ServerRep struct {
|
type ServerRep struct {
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
IP string `json:"ip"`
|
Address string `json:"address"`
|
||||||
ID string `json:"id"`
|
ID string `json:"id"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Default reply
|
// DefaultRep default reply
|
||||||
type DefaultRep struct {
|
type DefaultRep struct {
|
||||||
Error int64 `json:"error"`
|
Error int64 `json:"error"`
|
||||||
Message string `json:"message"`
|
Message string `json:"message"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Needed for Reply List
|
// ServerListRep collection of server replies
|
||||||
type ServerListRep struct {
|
type ServerListRep struct {
|
||||||
List []ServerRep
|
List []ServerRep
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reply DiskStats
|
// DiskStatsRep collection of disks
|
||||||
type DiskStatsRep struct {
|
type DiskStatsRep struct {
|
||||||
Disks []string
|
Disks []string
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reply MemStats
|
// MemStatsRep memory statistics of a server
|
||||||
type MemStatsRep struct {
|
type MemStatsRep struct {
|
||||||
Total uint64 `json:"total"`
|
Total uint64 `json:"total"`
|
||||||
Free uint64 `json:"free"`
|
Free uint64 `json:"free"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reply NetStats
|
// NetStatsRep network statistics of a server
|
||||||
type NetStatsRep struct {
|
type NetStatsRep struct {
|
||||||
Interfaces []Ifc
|
Interfaces []Network
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reply SysInfo
|
// SysInfoRep system information of a server
|
||||||
type SysInfoRep struct {
|
type SysInfoRep struct {
|
||||||
Hostname string `json:"hostname"`
|
Hostname string `json:"hostname"`
|
||||||
SysARCH string `json:"sys.arch"`
|
SysARCH string `json:"sysArch"`
|
||||||
SysOS string `json:"sys.os"`
|
SysOS string `json:"sysOS"`
|
||||||
SysCPUS int `json:"sys.ncpus"`
|
SysCPUS int `json:"sysNcpus"`
|
||||||
Routines int `json:"goroutines"`
|
Routines int `json:"goRoutines"`
|
||||||
GOVersion string `json:"goversion"`
|
GOVersion string `json:"goVersion"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reply List
|
// ListRep all servers list
|
||||||
type ListRep struct {
|
type ListRep struct {
|
||||||
List []ServerArg `json:"list"`
|
List []ServerArg `json:"list"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// VersionRep version reply
|
||||||
|
type VersionRep struct {
|
||||||
|
Version string `json:"version"`
|
||||||
|
BuildDate string `json:"buildDate"`
|
||||||
|
Architecture string `json:"arch"`
|
||||||
|
OperatingSystem string `json:"os"`
|
||||||
|
}
|
||||||
|
@ -46,19 +46,10 @@ EXAMPLES:
|
|||||||
`,
|
`,
|
||||||
}
|
}
|
||||||
|
|
||||||
// apiConfig - http server config
|
// configureAPIServer configure a new server instance
|
||||||
type apiConfig struct {
|
func configureAPIServer(conf minioConfig, apiHandler http.Handler) (*http.Server, *probe.Error) {
|
||||||
Address string
|
|
||||||
TLS bool
|
|
||||||
CertFile string
|
|
||||||
KeyFile string
|
|
||||||
RateLimit int
|
|
||||||
}
|
|
||||||
|
|
||||||
// getAPI server instance
|
|
||||||
func getAPIServer(conf apiConfig, apiHandler http.Handler) (*http.Server, *probe.Error) {
|
|
||||||
// Minio server config
|
// Minio server config
|
||||||
httpServer := &http.Server{
|
apiServer := &http.Server{
|
||||||
Addr: conf.Address,
|
Addr: conf.Address,
|
||||||
Handler: apiHandler,
|
Handler: apiHandler,
|
||||||
MaxHeaderBytes: 1 << 20,
|
MaxHeaderBytes: 1 << 20,
|
||||||
@ -66,9 +57,9 @@ func getAPIServer(conf apiConfig, apiHandler http.Handler) (*http.Server, *probe
|
|||||||
|
|
||||||
if conf.TLS {
|
if conf.TLS {
|
||||||
var err error
|
var err error
|
||||||
httpServer.TLSConfig = &tls.Config{}
|
apiServer.TLSConfig = &tls.Config{}
|
||||||
httpServer.TLSConfig.Certificates = make([]tls.Certificate, 1)
|
apiServer.TLSConfig.Certificates = make([]tls.Certificate, 1)
|
||||||
httpServer.TLSConfig.Certificates[0], err = tls.LoadX509KeyPair(conf.CertFile, conf.KeyFile)
|
apiServer.TLSConfig.Certificates[0], err = tls.LoadX509KeyPair(conf.CertFile, conf.KeyFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, probe.NewError(err)
|
return nil, probe.NewError(err)
|
||||||
}
|
}
|
||||||
@ -104,9 +95,29 @@ func getAPIServer(conf apiConfig, apiHandler http.Handler) (*http.Server, *probe
|
|||||||
} else {
|
} else {
|
||||||
fmt.Printf("Starting minio server on: http://%s:%s, PID: %d\n", host, port, os.Getpid())
|
fmt.Printf("Starting minio server on: http://%s:%s, PID: %d\n", host, port, os.Getpid())
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return httpServer, nil
|
return apiServer, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// configureServerRPC configure server rpc port
|
||||||
|
func configureServerRPC(conf minioConfig, rpcHandler http.Handler) (*http.Server, *probe.Error) {
|
||||||
|
// Minio server config
|
||||||
|
rpcServer := &http.Server{
|
||||||
|
Addr: conf.RPCAddress,
|
||||||
|
Handler: rpcHandler,
|
||||||
|
MaxHeaderBytes: 1 << 20,
|
||||||
|
}
|
||||||
|
|
||||||
|
if conf.TLS {
|
||||||
|
var err error
|
||||||
|
rpcServer.TLSConfig = &tls.Config{}
|
||||||
|
rpcServer.TLSConfig.Certificates = make([]tls.Certificate, 1)
|
||||||
|
rpcServer.TLSConfig.Certificates[0], err = tls.LoadX509KeyPair(conf.CertFile, conf.KeyFile)
|
||||||
|
if err != nil {
|
||||||
|
return nil, probe.NewError(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return rpcServer, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Start ticket master
|
// Start ticket master
|
||||||
@ -119,29 +130,33 @@ func startTM(a MinioAPI) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// startServer starts an s3 compatible cloud storage server
|
// startServer starts an s3 compatible cloud storage server
|
||||||
func startServer(conf apiConfig) *probe.Error {
|
func startServer(conf minioConfig) *probe.Error {
|
||||||
apiHandler, minioAPI := getAPIHandler()
|
minioAPI := getNewAPI()
|
||||||
apiServer, err := getAPIServer(conf, apiHandler)
|
apiHandler := getAPIHandler(minioAPI)
|
||||||
|
apiServer, err := configureAPIServer(conf, apiHandler)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err.Trace()
|
return err.Trace()
|
||||||
}
|
}
|
||||||
|
rpcServer, err := configureServerRPC(conf, getServerRPCHandler())
|
||||||
|
|
||||||
// start ticket master
|
// start ticket master
|
||||||
go startTM(minioAPI)
|
go startTM(minioAPI)
|
||||||
if err := minhttp.ListenAndServeLimited(conf.RateLimit, apiServer); err != nil {
|
if err := minhttp.ListenAndServe(apiServer, rpcServer); err != nil {
|
||||||
return err.Trace()
|
return err.Trace()
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func getServerConfig(c *cli.Context) apiConfig {
|
func getServerConfig(c *cli.Context) minioConfig {
|
||||||
certFile := c.GlobalString("cert")
|
certFile := c.GlobalString("cert")
|
||||||
keyFile := c.GlobalString("key")
|
keyFile := c.GlobalString("key")
|
||||||
if (certFile != "" && keyFile == "") || (certFile == "" && keyFile != "") {
|
if (certFile != "" && keyFile == "") || (certFile == "" && keyFile != "") {
|
||||||
Fatalln("Both certificate and key are required to enable https.")
|
Fatalln("Both certificate and key are required to enable https.")
|
||||||
}
|
}
|
||||||
tls := (certFile != "" && keyFile != "")
|
tls := (certFile != "" && keyFile != "")
|
||||||
return apiConfig{
|
return minioConfig{
|
||||||
Address: c.GlobalString("address"),
|
Address: c.GlobalString("address"),
|
||||||
|
RPCAddress: c.GlobalString("address-server-rpc"),
|
||||||
TLS: tls,
|
TLS: tls,
|
||||||
CertFile: certFile,
|
CertFile: certFile,
|
||||||
KeyFile: keyFile,
|
KeyFile: keyFile,
|
||||||
|
@ -80,7 +80,7 @@ func getNewAPI() MinioAPI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// getAPIHandler api handler
|
// getAPIHandler api handler
|
||||||
func getAPIHandler() (http.Handler, MinioAPI) {
|
func getAPIHandler(minioAPI MinioAPI) http.Handler {
|
||||||
var mwHandlers = []MiddlewareHandler{
|
var mwHandlers = []MiddlewareHandler{
|
||||||
ValidContentTypeHandler,
|
ValidContentTypeHandler,
|
||||||
TimeValidityHandler,
|
TimeValidityHandler,
|
||||||
@ -89,18 +89,16 @@ func getAPIHandler() (http.Handler, MinioAPI) {
|
|||||||
// api.LoggingHandler, // Disabled logging until we bring in external logging support
|
// api.LoggingHandler, // Disabled logging until we bring in external logging support
|
||||||
CorsHandler,
|
CorsHandler,
|
||||||
}
|
}
|
||||||
|
|
||||||
mux := router.NewRouter()
|
mux := router.NewRouter()
|
||||||
minioAPI := getNewAPI()
|
|
||||||
registerAPI(mux, minioAPI)
|
registerAPI(mux, minioAPI)
|
||||||
apiHandler := registerCustomMiddleware(mux, mwHandlers...)
|
apiHandler := registerCustomMiddleware(mux, mwHandlers...)
|
||||||
return apiHandler, minioAPI
|
return apiHandler
|
||||||
}
|
}
|
||||||
|
|
||||||
func getRPCServerHandler() http.Handler {
|
func getServerRPCHandler() http.Handler {
|
||||||
s := jsonrpc.NewServer()
|
s := jsonrpc.NewServer()
|
||||||
s.RegisterCodec(json.NewCodec(), "application/json")
|
s.RegisterCodec(json.NewCodec(), "application/json")
|
||||||
s.RegisterService(new(serverServerService), "Server")
|
s.RegisterService(new(serverRPCService), "Server")
|
||||||
mux := router.NewRouter()
|
mux := router.NewRouter()
|
||||||
mux.Handle("/rpc", s)
|
mux.Handle("/rpc", s)
|
||||||
return mux
|
return mux
|
||||||
|
@ -24,26 +24,26 @@ import (
|
|||||||
"github.com/minio/minio/pkg/probe"
|
"github.com/minio/minio/pkg/probe"
|
||||||
)
|
)
|
||||||
|
|
||||||
type serverServerService struct{}
|
type serverRPCService struct{}
|
||||||
|
|
||||||
func (s *serverServerService) Add(r *http.Request, arg *ServerArg, rep *DefaultRep) error {
|
func (s *serverRPCService) Add(r *http.Request, arg *ServerArg, rep *DefaultRep) error {
|
||||||
rep.Error = 0
|
rep.Error = 0
|
||||||
rep.Message = "Added successfully"
|
rep.Message = "Added successfully"
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *serverServerService) MemStats(r *http.Request, arg *ServerArg, rep *MemStatsRep) error {
|
func (s *serverRPCService) MemStats(r *http.Request, arg *ServerArg, rep *MemStatsRep) error {
|
||||||
rep.Total = 64 * 1024 * 1024 * 1024
|
rep.Total = 64 * 1024 * 1024 * 1024
|
||||||
rep.Free = 9 * 1024 * 1024 * 1024
|
rep.Free = 9 * 1024 * 1024 * 1024
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *serverServerService) DiskStats(r *http.Request, arg *ServerArg, rep *DiskStatsRep) error {
|
func (s *serverRPCService) DiskStats(r *http.Request, arg *ServerArg, rep *DiskStatsRep) error {
|
||||||
rep.Disks = []string{"/mnt/disk1", "/mnt/disk2", "/mnt/disk3", "/mnt/disk4", "/mnt/disk5", "/mnt/disk6"}
|
rep.Disks = []string{"/mnt/disk1", "/mnt/disk2", "/mnt/disk3", "/mnt/disk4", "/mnt/disk5", "/mnt/disk6"}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *serverServerService) SysInfo(r *http.Request, arg *ServerArg, rep *SysInfoRep) error {
|
func (s *serverRPCService) SysInfo(r *http.Request, arg *ServerArg, rep *SysInfoRep) error {
|
||||||
rep.SysARCH = runtime.GOARCH
|
rep.SysARCH = runtime.GOARCH
|
||||||
rep.SysOS = runtime.GOOS
|
rep.SysOS = runtime.GOOS
|
||||||
rep.SysCPUS = runtime.NumCPU()
|
rep.SysCPUS = runtime.NumCPU()
|
||||||
@ -57,7 +57,15 @@ func (s *serverServerService) SysInfo(r *http.Request, arg *ServerArg, rep *SysI
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *serverServerService) NetStats(r *http.Request, arg *ServerArg, rep *NetStatsRep) error {
|
func (s *serverRPCService) NetStats(r *http.Request, arg *ServerArg, rep *NetStatsRep) error {
|
||||||
rep.Interfaces = []Ifc{{"192.168.1.1", "255.255.255.0", "eth0"}}
|
rep.Interfaces = []Network{{"192.168.1.1", "255.255.255.0", "eth0"}}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *serverRPCService) Version(r *http.Request, arg *ServerArg, rep *VersionRep) error {
|
||||||
|
rep.Version = "0.0.1"
|
||||||
|
rep.BuildDate = minioVersion
|
||||||
|
rep.Architecture = runtime.GOARCH
|
||||||
|
rep.OperatingSystem = runtime.GOOS
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
132
server.go
132
server.go
@ -1,132 +0,0 @@
|
|||||||
/*
|
|
||||||
* Minio Cloud Storage, (C) 2014 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
|
|
||||||
<<<<<<< HEAD
|
|
||||||
|
|
||||||
import (
|
|
||||||
"crypto/tls"
|
|
||||||
"fmt"
|
|
||||||
"net"
|
|
||||||
"net/http"
|
|
||||||
"os"
|
|
||||||
"strings"
|
|
||||||
|
|
||||||
"github.com/minio/minio/pkg/minhttp"
|
|
||||||
"github.com/minio/minio/pkg/probe"
|
|
||||||
)
|
|
||||||
|
|
||||||
func configureServer(conf APIConfig, httpServer *http.Server) *probe.Error {
|
|
||||||
if conf.TLS {
|
|
||||||
var err error
|
|
||||||
httpServer.TLSConfig = &tls.Config{}
|
|
||||||
httpServer.TLSConfig.Certificates = make([]tls.Certificate, 1)
|
|
||||||
httpServer.TLSConfig.Certificates[0], err = tls.LoadX509KeyPair(conf.CertFile, conf.KeyFile)
|
|
||||||
if err != nil {
|
|
||||||
return probe.NewError(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
host, port, err := net.SplitHostPort(conf.Address)
|
|
||||||
if err != nil {
|
|
||||||
return probe.NewError(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
var hosts []string
|
|
||||||
switch {
|
|
||||||
case host != "":
|
|
||||||
hosts = append(hosts, host)
|
|
||||||
default:
|
|
||||||
addrs, err := net.InterfaceAddrs()
|
|
||||||
if err != nil {
|
|
||||||
return 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)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, host := range hosts {
|
|
||||||
if conf.TLS {
|
|
||||||
fmt.Printf("Starting minio server on: https://%s:%s, PID: %d\n", host, port, os.Getpid())
|
|
||||||
} else {
|
|
||||||
fmt.Printf("Starting minio server on: http://%s:%s, PID: %d\n", host, port, os.Getpid())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// getAPI server instance
|
|
||||||
func getAPIServer(conf APIConfig, apiHandler http.Handler) (*http.Server, *probe.Error) {
|
|
||||||
// Minio server config
|
|
||||||
httpServer := &http.Server{
|
|
||||||
Addr: conf.Address,
|
|
||||||
Handler: apiHandler,
|
|
||||||
MaxHeaderBytes: 1 << 20,
|
|
||||||
}
|
|
||||||
if err := configureServer(conf, httpServer); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return httpServer, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Start ticket master
|
|
||||||
func startTM(a MinioAPI) {
|
|
||||||
for {
|
|
||||||
for op := range a.OP {
|
|
||||||
op.ProceedCh <- struct{}{}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func getServerRPCServer(conf APIConfig, handler http.Handler) (*http.Server, *probe.Error) {
|
|
||||||
httpServer := &http.Server{
|
|
||||||
Addr: conf.AddressRPC,
|
|
||||||
Handler: handler,
|
|
||||||
MaxHeaderBytes: 1 << 20,
|
|
||||||
}
|
|
||||||
if err := configureServer(conf, httpServer); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return httpServer, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Start starts a s3 compatible cloud storage server
|
|
||||||
func StartServer(conf APIConfig) *probe.Error {
|
|
||||||
apiHandler, minioAPI := getAPIHandler(conf)
|
|
||||||
apiServer, err := getAPIServer(conf, apiHandler)
|
|
||||||
if err != nil {
|
|
||||||
return err.Trace()
|
|
||||||
}
|
|
||||||
// start ticket master
|
|
||||||
go startTM(minioAPI)
|
|
||||||
rpcHandler := getRPCServerHandler()
|
|
||||||
rpcServer, err := getServerRPCServer(conf, rpcHandler)
|
|
||||||
if err != nil {
|
|
||||||
return err.Trace()
|
|
||||||
}
|
|
||||||
if err := minhttp.ListenAndServeLimited(conf.RateLimit, apiServer, rpcServer); err != nil {
|
|
||||||
return err.Trace()
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
=======
|
|
||||||
>>>>>>> Consolidating more codebase and cleanup in server / controller
|
|
@ -51,9 +51,10 @@ func (s *MyAPIDonutCacheSuite) SetUpSuite(c *C) {
|
|||||||
perr := donut.SaveConfig(conf)
|
perr := donut.SaveConfig(conf)
|
||||||
c.Assert(perr, IsNil)
|
c.Assert(perr, IsNil)
|
||||||
|
|
||||||
httpHandler, minioAPI := getAPIHandler()
|
minioAPI := getNewAPI()
|
||||||
|
apiHandler := getAPIHandler(minioAPI)
|
||||||
go startTM(minioAPI)
|
go startTM(minioAPI)
|
||||||
testAPIDonutCacheServer = httptest.NewServer(httpHandler)
|
testAPIDonutCacheServer = httptest.NewServer(apiHandler)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *MyAPIDonutCacheSuite) TearDownSuite(c *C) {
|
func (s *MyAPIDonutCacheSuite) TearDownSuite(c *C) {
|
||||||
|
@ -70,7 +70,8 @@ func (s *MyAPIDonutSuite) SetUpSuite(c *C) {
|
|||||||
perr := donut.SaveConfig(conf)
|
perr := donut.SaveConfig(conf)
|
||||||
c.Assert(perr, IsNil)
|
c.Assert(perr, IsNil)
|
||||||
|
|
||||||
httpHandler, minioAPI := getAPIHandler()
|
minioAPI := getNewAPI()
|
||||||
|
httpHandler := getAPIHandler(minioAPI)
|
||||||
go startTM(minioAPI)
|
go startTM(minioAPI)
|
||||||
testAPIDonutServer = httptest.NewServer(httpHandler)
|
testAPIDonutServer = httptest.NewServer(httpHandler)
|
||||||
}
|
}
|
||||||
|
@ -78,7 +78,8 @@ func (s *MyAPISignatureV4Suite) SetUpSuite(c *C) {
|
|||||||
perr = auth.SaveConfig(authConf)
|
perr = auth.SaveConfig(authConf)
|
||||||
c.Assert(perr, IsNil)
|
c.Assert(perr, IsNil)
|
||||||
|
|
||||||
httpHandler, minioAPI := getAPIHandler()
|
minioAPI := getNewAPI()
|
||||||
|
httpHandler := getAPIHandler(minioAPI)
|
||||||
go startTM(minioAPI)
|
go startTM(minioAPI)
|
||||||
testSignatureV4Server = httptest.NewServer(httpHandler)
|
testSignatureV4Server = httptest.NewServer(httpHandler)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user