summaryrefslogtreecommitdiff
path: root/plugins/reload
diff options
context:
space:
mode:
authorValery Piashchynski <[email protected]>2021-01-21 13:25:36 +0300
committerValery Piashchynski <[email protected]>2021-01-21 13:25:36 +0300
commit7da6c78449776e1f3c6716250bca0b712a0423a4 (patch)
treef3512de66aca2bba408485a0ea2fc936c0e4fb9b /plugins/reload
parent0ff05b2732b4fd0783f959c94c54d7e39169f979 (diff)
Uniform all configs
Add debug server Check nil's for all plugin intialization
Diffstat (limited to 'plugins/reload')
-rw-r--r--plugins/reload/config.go10
-rw-r--r--plugins/reload/plugin.go10
2 files changed, 14 insertions, 6 deletions
diff --git a/plugins/reload/config.go b/plugins/reload/config.go
index 9bce6b25..6fd3af70 100644
--- a/plugins/reload/config.go
+++ b/plugins/reload/config.go
@@ -36,9 +36,13 @@ type ServiceConfig struct {
}
// InitDefaults sets missing values to their default values.
-func InitDefaults(c *Config) {
- c.Interval = time.Second
- c.Patterns = []string{".php"}
+func (c *Config) InitDefaults() {
+ if c.Interval == 0 {
+ c.Interval = time.Second
+ }
+ if c.Patterns == nil {
+ c.Patterns = []string{".php"}
+ }
}
// Valid validates the configuration.
diff --git a/plugins/reload/plugin.go b/plugins/reload/plugin.go
index 93760b8a..d76fb0a4 100644
--- a/plugins/reload/plugin.go
+++ b/plugins/reload/plugin.go
@@ -27,14 +27,18 @@ type Plugin struct {
// Init controller service
func (s *Plugin) Init(cfg config.Configurer, log logger.Logger, res resetter.Resetter) error {
const op = errors.Op("reload_plugin_init")
- s.cfg = &Config{}
- InitDefaults(s.cfg)
+ if !cfg.Has(PluginName) {
+ return errors.E(op, errors.Disabled)
+ }
+
err := cfg.UnmarshalKey(PluginName, &s.cfg)
if err != nil {
// disable plugin in case of error
return errors.E(op, errors.Disabled, err)
}
+ s.cfg.InitDefaults()
+
s.log = log
s.res = res
s.stopc = make(chan struct{}, 1)
@@ -101,7 +105,7 @@ func (s *Plugin) Serve() chan error {
}
}()
- // map with configs by services
+ // map with config by services
updated := make(map[string]ServiceConfig, len(s.cfg.Services))
go func() {