2 // ========================LICENSE_START=================================
5 // Copyright (C) 2022: Nordix Foundation
7 // Licensed under the Apache License, Version 2.0 (the "License");
8 // you may not use this file except in compliance with the License.
9 // You may obtain a copy of the License at
11 // http://www.apache.org/licenses/LICENSE-2.0
13 // Unless required by applicable law or agreed to in writing, software
14 // distributed under the License is distributed on an "AS IS" BASIS,
15 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 // See the License for the specific language governing permissions and
17 // limitations under the License.
18 // ========================LICENSE_END===================================
29 log "github.com/sirupsen/logrus"
30 "oransc.org/usecase/oduclosedloop/icsversion/internal/config"
31 sliceassurance "oransc.org/usecase/oduclosedloop/icsversion/internal/odusliceassurance"
34 var configuration *config.Configuration
35 var a sliceassurance.App
38 configuration = config.New()
40 log.SetLevel(configuration.LogLevel)
41 log.SetFormatter(&log.JSONFormatter{})
43 log.Debug("Using configuration: ", configuration)
45 if err := validateConfiguration(configuration); err != nil {
46 log.Fatalf("Unable to start consumer due to configuration error: %v", err)
49 a = sliceassurance.App{}
50 a.Initialize(configuration)
54 os.Exit(1) // If the startServer function exits, it is because there has been a failure in the server, so we exit.
59 func validateConfiguration(configuration *config.Configuration) error {
60 if configuration.ConsumerHost == "" || configuration.ConsumerPort == 0 {
61 return fmt.Errorf("consumer host and port must be provided")
62 } else if configuration.NodeId == "" {
63 return fmt.Errorf("NodeId must be provided")
68 func keepConsumerAlive() {
69 exitSignal := make(chan os.Signal, 1)
70 signal.Notify(exitSignal, syscall.SIGINT, syscall.SIGTERM)