Skip to content

Commit

Permalink
fix: termination optimization and comply with NetworkFunction
Browse files Browse the repository at this point in the history
  • Loading branch information
andy89923 committed Apr 30, 2024
1 parent 0e784bc commit e9da28f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func action(cliCtx *cli.Context) error {
}
CHF = chf

chf.Start()
chf.Start(tlsKeyLogPath)
CHF.WaitRoutineStopped()

return nil
Expand Down
11 changes: 7 additions & 4 deletions pkg/service/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,8 @@ func (c *ChfApp) SetReportCaller(reportCaller bool) {
logger.Log.SetReportCaller(reportCaller)
}

func (a *ChfApp) Start() {
// tlsKeyLogPath have to remove after all NFs are refactor
func (a *ChfApp) Start(tlsKeyLogPath string) {
logger.InitLog.Infoln("Server started")

a.wg.Add(1)
Expand Down Expand Up @@ -160,11 +161,14 @@ func (a *ChfApp) listenShutdownEvent() {
}()

<-a.ctx.Done()
a.Stop()
a.Terminate()
}

func (c *ChfApp) Terminate() {
logger.MainLog.Infof("Terminating CHF...")
c.cancel()
c.CallServerStop()

// deregister with NRF
problemDetails, err := c.Consumer().SendDeregisterNFInstance()
if problemDetails != nil {
Expand All @@ -177,10 +181,9 @@ func (c *ChfApp) Terminate() {
logger.MainLog.Infof("CHF SBI Server terminated")
}

func (a *ChfApp) Stop() {
func (a *ChfApp) CallServerStop() {
if a.sbiServer != nil {
a.sbiServer.Stop()
a.Terminate()
}
}

Expand Down

0 comments on commit e9da28f

Please sign in to comment.