diff --git a/nucleus/controller.go b/nucleus/controller.go index bb928f4ae44ba399da1b7e3262e7700380eb546d..fc832735f546d22f7430fce94464003373e8f29c 100644 --- a/nucleus/controller.go +++ b/nucleus/controller.go @@ -47,19 +47,8 @@ func initialize() error { } // TODO: Start grpc listener here - if err := httpAPI(); err != nil { - return err - } - - attachDatabase() - - return nil -} -// deprecated -// attachDatabase connects to the database and passes the connection to the controller core -func attachDatabase() { - c.database = database.NewDatabaseClient() + return httpAPI() } // createSouthboundInterfaces initializes the controller with its supported SBIs diff --git a/nucleus/http.go b/nucleus/http.go index 41fea9aaa78245df4bf991451beb65743dc5b127..1869f27e7124151ac1803318f33f6581ac426ab9 100644 --- a/nucleus/http.go +++ b/nucleus/http.go @@ -9,12 +9,9 @@ import ( log "github.com/sirupsen/logrus" "net/http" "net/url" - "sync" "time" ) -var httpOnce sync.Once - func stopHttpServer() error { ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second) defer cancel() @@ -35,15 +32,10 @@ func registerHttpHandler() { // deprecated func httpAPI() (err error) { - coreLock.Lock() - defer coreLock.Unlock() - httpOnce.Do(registerHttpHandler) + registerHttpHandler() c.httpServer = &http.Server{Addr: ":8080"} go func() { - err = c.httpServer.ListenAndServe() - if err != nil { - return - } + log.Info(c.httpServer.ListenAndServe()) }() return nil }