+func queryXAppsStatus(appmgrUrl string, timeout time.Duration) ([]byte, error) {
+
+ logger.Info("query xAppStatus started, url %s", appmgrUrl)
+ req, err := http.NewRequest("GET", appmgrUrl, nil)
+ if err != nil {
+ logger.Error("Failed to create a HTTP request: %s", err)
+ return nil, err
+ }
+ req.Header.Set("Content-Type", "application/json")
+ client := &http.Client{}
+ client.Timeout = time.Second * timeout
+ resp, err := client.Do(req)
+ if err != nil {
+ logger.Error("Query xApp status failed: %s", err)
+ return nil, err
+ }
+ defer resp.Body.Close()
+ if resp.StatusCode == http.StatusOK {
+ body, err := ioutil.ReadAll(resp.Body)
+ if err != nil {
+ logger.Error("Failed to read xApp status body: %s", err)
+ return nil, err
+ }
+ logger.Info("query xAppStatus completed")
+ return body, nil
+ } else {
+ logger.Error("Error from xApp status query: %s", resp.Status)
+ return nil, errors.New(resp.Status)
+ }
+}
+
+type state int
+
+const (
+ normalState state = iota
+ vespaTerminatingState state = iota
+)
+
+func queryConf() ([]byte, error) {
+ return queryXAppsStatus("http://"+appmgrDomain+":"+appmgrPort+appmgrXAppConfigPath,
+ 10*time.Second)
+}
+
+func runVesmgr(chVesagent chan error, chSupervision chan chan string, chXAppNotifications chan []byte, chXAppSubscriptions chan subsChannel) {
+
+ logger.Info("vesmgr main loop ready")
+ mystate := normalState
+ var xappStatus []byte