Discovery Nats automate
This commit is contained in:
parent
9c0107e87c
commit
c8a1377851
@ -91,28 +91,12 @@ func Init(appName string, hostname string, port string) {
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
tools.UncatchedError = append(tools.UncatchedError, errors.New("Panic recovered in Init : "+fmt.Sprintf("%v", r)+" - "+string(debug.Stack())))
|
||||
fmt.Printf("Panic recovered in Init : %v - %v\n", r, string(debug.Stack()))
|
||||
}
|
||||
}()
|
||||
logs.SetAppName(appName)
|
||||
logs.SetLogger(logs.CreateLogger("main", ""))
|
||||
logger := logs.GetLogger()
|
||||
discoveryAccess := (&discovery.Discovery{}).GetAccessor(nil)
|
||||
res, code, _ := discoveryAccess.Search(nil, appName)
|
||||
initial := &discovery.Discovery{
|
||||
AbstractObject: utils.AbstractObject{
|
||||
Name: appName,
|
||||
},
|
||||
Host: hostname,
|
||||
Port: port,
|
||||
State: 1,
|
||||
}
|
||||
if code == 200 && len(res) == 0 {
|
||||
discoveryAccess.StoreOne(initial)
|
||||
}
|
||||
err := tools.NewNATSCaller().DiscoveryNATS(appName, initial)
|
||||
if err != nil {
|
||||
logger.Error().Msg(err.Error())
|
||||
}
|
||||
mongo.MONGOService.Init(models.GetModelsNames(), tools.GetConfig())
|
||||
accessor := (&resource_model.ResourceModel{}).GetAccessor(nil)
|
||||
for _, model := range []string{utils.DATA_RESOURCE.String(), utils.PROCESSING_RESOURCE.String(), utils.STORAGE_RESOURCE.String(), utils.DATACENTER_RESOURCE.String(), utils.WORKFLOW_RESOURCE.String()} {
|
||||
@ -139,6 +123,23 @@ func Init(appName string, hostname string, port string) {
|
||||
})
|
||||
}
|
||||
}
|
||||
discoveryAccess := (&discovery.Discovery{}).GetAccessor(nil)
|
||||
res, code, _ := discoveryAccess.Search(nil, appName)
|
||||
initial := &discovery.Discovery{
|
||||
AbstractObject: utils.AbstractObject{
|
||||
Name: appName,
|
||||
},
|
||||
Host: hostname,
|
||||
Port: port,
|
||||
State: 1,
|
||||
}
|
||||
if code == 200 && len(res) == 0 {
|
||||
discoveryAccess.StoreOne(initial)
|
||||
}
|
||||
err := tools.NewNATSCaller().DiscoveryNATS(appName, initial)
|
||||
if err != nil {
|
||||
logger.Error().Msg(err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
func GetLogger() zerolog.Logger {
|
||||
|
Loading…
Reference in New Issue
Block a user