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
|
package server
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"net/url"
|
|
||||||
"strconv"
|
|
||||||
|
|
||||||
"github.com/BBVA/kapow/internal/server/control"
|
"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
|
// 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 {
|
func StartServer(controlBindAddr, dataBindAddr, userBindAddr string) {
|
||||||
|
go control.Run(controlBindAddr)
|
||||||
// Parse URI and manage parameters to extract
|
go data.Run(dataBindAddr)
|
||||||
userBindAddr, err := url.Parse(bindAddr)
|
go user.Run(userBindAddr)
|
||||||
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)
|
|
||||||
|
|
||||||
// Wait for ever
|
// Wait for ever
|
||||||
select {}
|
select {}
|
||||||
|
|||||||
Reference in New Issue
Block a user