diff --git a/database/storage/bbolt/bbolt.go b/database/storage/bbolt/bbolt.go index 5291e0c..214605c 100644 --- a/database/storage/bbolt/bbolt.go +++ b/database/storage/bbolt/bbolt.go @@ -32,8 +32,18 @@ func init() { // NewBBolt opens/creates a bbolt database. func NewBBolt(name, location string) (storage.Interface, error) { + // Create options for bbolt database. + dbFile := filepath.Join(location, "db.bbolt") + dbOptions := &bbolt.Options{ + Timeout: 1 * time.Second, + } - db, err := bbolt.Open(filepath.Join(location, "db.bbolt"), 0600, nil) + // Open/Create database, retry if there is a timeout. + db, err := bbolt.Open(dbFile, 0600, dbOptions) + for i := 0; i < 5 && err != nil; i++ { + // Try again if there is an error. + db, err = bbolt.Open(dbFile, 0600, dbOptions) + } if err != nil { return nil, err } diff --git a/modules/start.go b/modules/start.go index fb2d24a..b422def 100644 --- a/modules/start.go +++ b/modules/start.go @@ -173,6 +173,13 @@ func startModules() error { case statusReady: execCnt++ m.start(reports) + // DEBUG SNIPPET + // Slow-start for non-attributable performance issues. + // If you use subsystems, you'll need the snippet there too. + // log.Errorf("modules: starting %s", m.Name) + // time.Sleep(10 * time.Second) + // break + // END DEBUG SNIPPET } } diff --git a/modules/subsystems/registry.go b/modules/subsystems/registry.go index 1da1587..bc16944 100644 --- a/modules/subsystems/registry.go +++ b/modules/subsystems/registry.go @@ -187,6 +187,11 @@ func (mng *Manager) shouldServeUpdates() bool { // CheckConfig checks subsystem configuration values and enables // or disables subsystems and their dependencies as required. func (mng *Manager) CheckConfig(ctx context.Context) error { + // DEBUG SNIPPET + // Slow-start for non-attributable performance issues. + // You'll need the snippet in the modules too. + // time.Sleep(11 * time.Second) + // END DEBUG SNIPPET return mng.handleConfigChanges(ctx) } diff --git a/updater/storage.go b/updater/storage.go index 55f78fe..443d82c 100644 --- a/updater/storage.go +++ b/updater/storage.go @@ -51,11 +51,6 @@ func (reg *ResourceRegistry) ScanStorage(root string) error { return nil } - // ignore directories - if info.IsDir() { - return nil - } - // get relative path to storage relativePath, err := filepath.Rel(reg.storageDir.Path, path) if err != nil { @@ -72,6 +67,11 @@ func (reg *ResourceRegistry) ScanStorage(root string) error { return nil } + // fully ignore directories that also have an identifier - these will be unpacked resources + if info.IsDir() { + return filepath.SkipDir + } + // save err = reg.AddResource(identifier, version, true, false, false) if err != nil {