Implement server.StartServer() to run all three servers
Co-authored-by: Hector Hurtado <hector.hurtado@bbva.com>
This commit is contained in:
@@ -1,34 +1,16 @@
|
||||
package server
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/url"
|
||||
"strconv"
|
||||
|
||||
"github.com/BBVA/kapow/internal/server/control"
|
||||
"github.com/BBVA/kapow/internal/server/data"
|
||||
"github.com/BBVA/kapow/internal/server/user"
|
||||
)
|
||||
|
||||
// StartServer Starts one instance of each server in a goroutine and remains listening on a channel for trace events generated by them
|
||||
func StartServer(bindAddr, certfile, keyfile string, interactive bool) error {
|
||||
|
||||
// Parse URI and manage parameters to extract
|
||||
userBindAddr, err := url.Parse(bindAddr)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
userPort, err := strconv.ParseInt(userBindAddr.Port(), 10, 64)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error extracting port from provided address %s", bindAddr)
|
||||
}
|
||||
|
||||
ctrlBindAddr := fmt.Sprintf("%s:%d", userBindAddr.Host, userPort+1)
|
||||
dataBindAddr := fmt.Sprintf("%s:%d", userBindAddr.Host, userPort+2)
|
||||
|
||||
fmt.Printf("User server bind address: %s, Control server bind address: %s, Data server bind address: %s", bindAddr, ctrlBindAddr, dataBindAddr)
|
||||
go control.Run(ctrlBindAddr)
|
||||
//go dataServer.Start(traceChannel)
|
||||
//go ctrlServer.Start(traceChannel)
|
||||
func StartServer(controlBindAddr, dataBindAddr, userBindAddr string) {
|
||||
go control.Run(controlBindAddr)
|
||||
go data.Run(dataBindAddr)
|
||||
go user.Run(userBindAddr)
|
||||
|
||||
// Wait for ever
|
||||
select {}
|
||||
|
||||
Reference in New Issue
Block a user