Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
W
webconsole
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pqc-free5gc
webconsole
Commits
ed393973
Unverified
Commit
ed393973
authored
1 year ago
by
CTFang@WireLab
Browse files
Options
Downloads
Patches
Plain Diff
refactor: use http server to serve and graceful shutdown
parent
a4831ec6
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
backend/webui_service/webui_init.go
+31
-6
31 additions, 6 deletions
backend/webui_service/webui_init.go
with
31 additions
and
6 deletions
backend/webui_service/webui_init.go
+
31
−
6
View file @
ed393973
package
webui_service
import
(
"context"
"io"
"net/http"
"os"
"os/signal"
"runtime/debug"
"sync"
"syscall"
"time"
"github.com/gin-contrib/cors"
"github.com/sirupsen/logrus"
...
...
@@ -23,8 +26,8 @@ type WebuiApp struct {
cfg
*
factory
.
Config
webuiCtx
*
webui_context
.
WEBUIContext
wg
*
sync
.
WaitGroup
wg
*
sync
.
WaitGroup
server
*
http
.
Server
billingServer
*
billing
.
BillingDomain
}
...
...
@@ -155,23 +158,45 @@ func (a *WebuiApp) Start(tlsKeyLogPath string) {
router
.
NoRoute
(
ReturnPublic
())
var
addr
string
if
webServer
!=
nil
{
logger
.
InitLog
.
Infoln
(
router
.
Run
(
webServer
.
IP
+
":"
+
webServer
.
PORT
))
addr
=
webServer
.
IP
+
":"
+
webServer
.
PORT
}
else
{
logger
.
InitLog
.
Infoln
(
router
.
Run
(
":5000"
))
addr
=
":5000"
}
a
.
server
=
&
http
.
Server
{
Addr
:
addr
,
Handler
:
router
,
}
go
func
()
{
logger
.
MainLog
.
Infof
(
"Http server listening on %+v"
,
addr
)
if
err
:=
a
.
server
.
ListenAndServe
();
err
!=
nil
&&
err
!=
http
.
ErrServerClosed
{
logger
.
MainLog
.
Fatalf
(
"listen: %s
\n
"
,
err
)
}
}()
logger
.
MainLog
.
Infoln
(
"wait all routine stopped"
)
a
.
wg
.
Wait
()
}
func
(
a
*
WebuiApp
)
Terminate
()
{
logger
.
Init
Log
.
Infoln
(
"Terminating WebUI-AF..."
)
logger
.
Main
Log
.
Infoln
(
"Terminating WebUI-AF..."
)
if
a
.
billingServer
!=
nil
{
a
.
billingServer
.
Stop
()
}
if
a
.
server
!=
nil
{
logger
.
MainLog
.
Infoln
(
"stopping HTTP server"
)
ctx
,
cancel
:=
context
.
WithTimeout
(
context
.
Background
(),
3
*
time
.
Second
)
defer
cancel
()
if
err
:=
a
.
server
.
Shutdown
(
ctx
);
err
!=
nil
{
logger
.
MainLog
.
Fatal
(
"HTTP server forced to shutdown: "
,
err
)
}
}
// Deregister with NRF
if
a
.
webuiCtx
.
IsRegistered
{
problemDetails
,
err
:=
webui_context
.
SendDeregisterNFInstance
()
...
...
@@ -184,5 +209,5 @@ func (a *WebuiApp) Terminate() {
}
}
logger
.
Init
Log
.
Infoln
(
"WebUI-AF Terminated"
)
logger
.
Main
Log
.
Infoln
(
"WebUI-AF Terminated"
)
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment