@@ -19,6 +19,7 @@ import (
1919
2020 // "log"
2121 "os/signal"
22+ "strings"
2223 "sync"
2324 "syscall"
2425 "time"
@@ -28,6 +29,7 @@ import (
2829
2930 "github.com/rs/zerolog/log"
3031
32+ "github.com/cloud-barista/cb-tumblebug/src/api/rest/docs"
3133 "github.com/cloud-barista/cb-tumblebug/src/api/rest/server/auth"
3234
3335 rest_common "github.com/cloud-barista/cb-tumblebug/src/api/rest/server/common"
@@ -88,7 +90,7 @@ const (
8890)
8991
9092// RunServer func start Rest API server
91- func RunServer (port string ) {
93+ func RunServer () {
9294
9395 log .Info ().Msg ("REST API Server is starting" )
9496
@@ -119,6 +121,7 @@ func RunServer(port string) {
119121 //e.colorer.Printf(banner, e.colorer.Red("v"+Version), e.colorer.Blue(website))
120122
121123 // Route for system management
124+ docs .SwaggerInfo .Host = model .SelfEndpoint
122125 swaggerRedirect := func (c echo.Context ) error {
123126 return c .Redirect (http .StatusMovedPermanently , "/tumblebug/api/index.html" )
124127 }
@@ -515,10 +518,14 @@ func RunServer(port string) {
515518 g .PUT ("/:nsId/testDeleteObjectAssociation/:resourceType/:resourceId" , rest_resource .RestTestDeleteObjectAssociation )
516519 g .GET ("/:nsId/testGetAssociatedObjectCount/:resourceType/:resourceId" , rest_resource .RestTestGetAssociatedObjectCount )
517520
518- selfEndpoint := os .Getenv ("TB_SELF_ENDPOINT" )
519- apiServer := "http://" + selfEndpoint + "/tumblebug/readyz"
520- apiDashboard := "http://localhost:1325"
521- mapUI := "http://localhost:1324"
521+ selfEndpoint := strings .Split (model .SelfEndpoint , ":" )
522+ selfIp := selfEndpoint [0 ]
523+ selfPort := selfEndpoint [1 ]
524+
525+ apiServer := fmt .Sprintf ("http://%s:%s/tumblebug/readyz" , selfIp , selfPort )
526+ //apiDashboard := fmt.Sprintf("http://%s:%s", selfIp, "1325")
527+ apiDashboard := fmt .Sprintf ("http://%s:%s/tumblebug/api" , selfIp , selfPort )
528+ mapUI := fmt .Sprintf ("http://%s:%s" , selfIp , "1324" )
522529
523530 fmt .Print (resetColor )
524531 fmt .Printf (" Default Namespace: %s%s%s\n " , warningColor , model .DefaultNamespace , resetColor )
@@ -565,9 +572,8 @@ func RunServer(port string) {
565572 }
566573 }(& wg )
567574
568- port = fmt .Sprintf (":%s" , port )
569575 model .SystemReady = true
570- if err := e .Start (port ); err != nil && err != http .ErrServerClosed {
576+ if err := e .Start (":" + selfPort ); err != nil && err != http .ErrServerClosed {
571577 log .Error ().Err (err ).Msg ("Error in Starting CB-Tumblebug API Server" )
572578 e .Logger .Panic ("Shuttig down the server: " , err )
573579 }
0 commit comments