Browse Source

Fix rule-set not closed

世界 9 months ago
parent
commit
9b4c11ba95
2 changed files with 8 additions and 1 deletions
  1. 7 0
      route/router.go
  2. 1 1
      route/rule/rule_set_local.go

+ 7 - 0
route/router.go

@@ -484,6 +484,13 @@ func (r *Router) Close() error {
 		})
 		monitor.Finish()
 	}
+	for i, ruleSet := range r.ruleSets {
+		monitor.Start("close rule-set[", i, "]")
+		err = E.Append(err, ruleSet.Close(), func(err error) error {
+			return E.Cause(err, "close rule-set[", i, "]")
+		})
+		monitor.Finish()
+	}
 	return err
 }
 

+ 1 - 1
route/rule/rule_set_local.go

@@ -56,7 +56,7 @@ func NewLocalRuleSet(ctx context.Context, logger logger.Logger, options option.R
 		}
 	} else {
 		filePath := filemanager.BasePath(ctx, options.LocalOptions.Path)
-		filePath, _ = filepath.Abs(options.LocalOptions.Path)
+		filePath, _ = filepath.Abs(filePath)
 		err := ruleSet.reloadFile(filePath)
 		if err != nil {
 			return nil, err