Added target and terminal support.
[src/xds/xds-server.git] / lib / xdsserver / sdks.go
index c006861..4a7ba84 100644 (file)
@@ -38,8 +38,8 @@ type SDKs struct {
        stop  chan struct{} // signals intentional stop
 }
 
-// NewSDKs creates a new instance of SDKs
-func NewSDKs(ctx *Context) (*SDKs, error) {
+// SDKsConstructor creates a new instance of SDKs
+func SDKsConstructor(ctx *Context) (*SDKs, error) {
        s := SDKs{
                Context:      ctx,
                Sdks:         make(map[string]*CrossSDK),
@@ -63,6 +63,12 @@ func NewSDKs(ctx *Context) (*SDKs, error) {
                return &s, err
        }
 
+       // Update SDK DB on startup by default (can be disable using config file)
+       update := true
+       if s.Config.FileConf.SdkDbUpdate != "startup" {
+               update = false
+       }
+
        s.mutex.Lock()
        defer s.mutex.Unlock()
 
@@ -73,10 +79,11 @@ func NewSDKs(ctx *Context) (*SDKs, error) {
                        continue
                }
 
-               sdksList, err := ListCrossSDK(d, s.Log)
+               sdksList, err := ListCrossSDK(d, update, s.Log)
                if err != nil {
                        // allow to use XDS even if error on list
                        s.Log.Errorf("Cannot retrieve SDK list: %v", err)
+                       sdksList, _ = ListCrossSDK(d, false, s.Log)
                }
                s.LogSillyf("'%s' SDKs list: %v", d, sdksList)