|
|
@@ -4,6 +4,7 @@ import (
|
|
|
"encoding/json"
|
|
|
"fmt"
|
|
|
"net/http"
|
|
|
+ "strings"
|
|
|
"sync"
|
|
|
|
|
|
"github.com/coroot/coroot-node-agent/flags"
|
|
|
@@ -23,8 +24,9 @@ const (
|
|
|
reportTaskResultModel
|
|
|
installReportModel
|
|
|
|
|
|
- urlModel = "%s/api/ext/gaia/daemon/%s"
|
|
|
- urlModel_ = "%s/api/ext/gaia/daemon/%s/%s"
|
|
|
+ urlModel = "%s/api/ext/gaia/daemon/%s"
|
|
|
+ urlModel_ = "%s/api/ext/gaia/daemon/%s/%s"
|
|
|
+ doopUriKeyword = "doop-agent-api"
|
|
|
)
|
|
|
|
|
|
type ServerWorker interface {
|
|
|
@@ -114,6 +116,25 @@ func (w *ServerHTTPWorker) RegisterApp(request RegisterAppReq) error {
|
|
|
log.WithError(err).Errorf("[server register] Failed RegisterApp request:%v.", utils.ToString(request))
|
|
|
return err
|
|
|
}
|
|
|
+
|
|
|
+ if *flags.RegisterAppToDoop {
|
|
|
+ if len(w.proxyClient.Endpoints) > 0 {
|
|
|
+ endpointUrl := w.proxyClient.Endpoints[0].Url
|
|
|
+ if !strings.Contains(endpointUrl, doopUriKeyword) {
|
|
|
+ doopUriPrefix := "/" + doopUriKeyword
|
|
|
+ if strings.HasSuffix(endpointUrl, "/") {
|
|
|
+ doopUriPrefix = doopUriKeyword
|
|
|
+ }
|
|
|
+ // 再次调用注册接口,向doop注册app信息
|
|
|
+ _, err := w.requestServer(doopUriPrefix+"/v2/app/create", request)
|
|
|
+ if err != nil {
|
|
|
+ log.WithError(err).Errorf("[server register] Failed RegisterApp to DOOP request:%v.", utils.ToString(request))
|
|
|
+ return err
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
return nil
|
|
|
}
|
|
|
|