Prepare to merge master
This commit is contained in:
@@ -2,14 +2,8 @@ package server
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"net/url"
|
||||
"os"
|
||||
"strconv"
|
||||
|
||||
"github.com/BBVA/kapow/server/control"
|
||||
"github.com/BBVA/kapow/server/data"
|
||||
"github.com/BBVA/kapow/server/user"
|
||||
)
|
||||
|
||||
// StartServer Starts one instance of each server in a goroutine and remains listening on a channel for trace events generated by them
|
||||
@@ -26,37 +20,14 @@ func StartServer(bindAddr, certfile, keyfile string, interactive bool) error {
|
||||
return fmt.Errorf("Error extracting port from provided address %s", bindAddr)
|
||||
}
|
||||
|
||||
if certfile != "" {
|
||||
if _, err := os.Stat(certfile); err != nil {
|
||||
if os.IsNotExist(err) {
|
||||
return fmt.Errorf("Certfile %s does not exist", certfile)
|
||||
}
|
||||
}
|
||||
}
|
||||
ctrlBindAddr := fmt.Sprintf("%s:%d", userBindAddr.Host, userPort+1)
|
||||
dataBindAddr := fmt.Sprintf("%s:%d", userBindAddr.Host, userPort+2)
|
||||
|
||||
if keyfile != "" {
|
||||
if _, err := os.Stat(keyfile); err != nil {
|
||||
if os.IsNotExist(err) {
|
||||
return fmt.Errorf("Keyfile %s does not exist", keyfile)
|
||||
}
|
||||
}
|
||||
}
|
||||
fmt.Printf("User server bind address: %s, Control server bind address: %s, Data server bind address: %s", bindAddr, ctrlBindAddr, dataBindAddr)
|
||||
//go ctrlServer.Start(traceChannel)
|
||||
//go dataServer.Start(traceChannel)
|
||||
//go ctrlServer.Start(traceChannel)
|
||||
|
||||
ctrlPort := userPort + 1
|
||||
dataPort := ctrlPort + 1
|
||||
|
||||
dataServer := data.NewDataServer(userBindAddr.Host(), dataPort, certfile, keyfile)
|
||||
ctrlServer := control.NewControlServer(userBindAddr.Host(), ctrlPort, certfile, keyfile) // Needs a reference to the user server in order to manage routes
|
||||
userServer := user.NewUserServer(userBindAddr.Host(), controlServerPort, certfile, keyfile) // Needs a reference to the data server in order to manage handlers
|
||||
|
||||
traceChannel := make(chan string)
|
||||
|
||||
go ctrlServer.Start(traceChannel)
|
||||
go dataServer.Start(traceChannel)
|
||||
go ctrlServer.Start(traceChannel)
|
||||
|
||||
// Wait for ever while writing logs
|
||||
for {
|
||||
log.Print(<-traceChannel)
|
||||
}
|
||||
// Wait for ever
|
||||
select {}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ package server_test
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/BBVA/kapow/server"
|
||||
"github.com/BBVA/kapow/internal/server"
|
||||
)
|
||||
|
||||
func TestStartServerWhenInvalidBindAddrReturnsError(t *testing.T) {
|
||||
@@ -21,19 +21,3 @@ func TestStartServerWhenInvalidPortNumberReturnsError(t *testing.T) {
|
||||
t.Errorf("Expected error not found")
|
||||
}
|
||||
}
|
||||
|
||||
func TestStartServerWhenCertfileDontExistReturnsError(t *testing.T) {
|
||||
|
||||
err := server.StartServer("0.0.0.0:8080", "/notExist", "", true)
|
||||
if err == nil {
|
||||
t.Errorf("Expected error not found")
|
||||
}
|
||||
}
|
||||
|
||||
func TestStartServerWhenKeyfileDontExistReturnsError(t *testing.T) {
|
||||
|
||||
err := server.StartServer("0.0.0.0:8080", "", "/notExist", true)
|
||||
if err == nil {
|
||||
t.Errorf("Expected error not found")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user