Skip to content

Commit

Permalink
feat(config): billing server feature toggle
Browse files Browse the repository at this point in the history
  • Loading branch information
yccodr committed Mar 11, 2024
1 parent 3c7fdc4 commit 9471dba
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
1 change: 1 addition & 0 deletions backend/factory/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ type Tls struct {
}

type BillingServer struct {
Enabled bool `yaml:"enabled" valid:"type(bool), default(true)"`
HostIPv4 string `yaml:"hostIPv4,omitempty" valid:"required,host"`
Port int `yaml:"port,omitempty" valid:"optional,port"`
ListenPort int `yaml:"listenPort,omitempty" valid:"required,port"`
Expand Down
11 changes: 7 additions & 4 deletions backend/webui_service/webui_init.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ func (a *WebuiApp) Start(tlsKeyLogPath string) {
// get config file info from WebUIConfig
mongodb := factory.WebuiConfig.Configuration.Mongodb
webServer := factory.WebuiConfig.Configuration.WebServer
billingServer := factory.WebuiConfig.Configuration.BillingServer

// Connect to MongoDB
if err := mongoapi.SetMongoDB(mongodb.Name, mongodb.Url); err != nil {
Expand Down Expand Up @@ -108,11 +109,13 @@ func (a *WebuiApp) Start(tlsKeyLogPath string) {
self.UpdateNfProfiles()

wg := sync.WaitGroup{}
wg.Add(1)

self.BillingServer = billing.OpenServer(&wg)
if self.BillingServer == nil {
logger.InitLog.Errorln("Billing Server open error.")
if billingServer.Enabled {
wg.Add(1)
self.BillingServer = billing.OpenServer(&wg)
if self.BillingServer == nil {
logger.InitLog.Errorln("Billing Server open error.")
}
}

router.NoRoute(ReturnPublic())
Expand Down
1 change: 1 addition & 0 deletions config/webuicfg.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ configuration:
ipv4Address: 0.0.0.0
port: 5000
billingServer:
enable: true
hostIPv4: 127.0.0.1
listenPort: 2122
port: 2121
Expand Down

0 comments on commit 9471dba

Please sign in to comment.