summaryrefslogtreecommitdiff
path: root/service/reload/config.go
diff options
context:
space:
mode:
Diffstat (limited to 'service/reload/config.go')
-rw-r--r--service/reload/config.go21
1 files changed, 20 insertions, 1 deletions
diff --git a/service/reload/config.go b/service/reload/config.go
index 551fb71b..930f4dff 100644
--- a/service/reload/config.go
+++ b/service/reload/config.go
@@ -1,6 +1,7 @@
package reload
import (
+ "errors"
"github.com/spiral/roadrunner"
"github.com/spiral/roadrunner/service"
"time"
@@ -41,6 +42,24 @@ func (c *Config) Hydrate(cfg service.Config) error {
// InitDefaults sets missing values to their default values.
func (c *Config) InitDefaults() error {
- c.Enabled = false
+ return c.Valid()
+}
+
+// Valid validates the configuration.
+func (c *Config) Valid() error {
+ if c.Enabled == true && c.Interval < time.Second {
+ return errors.New("too short interval")
+ }
+
+ if c.Enabled {
+ if c.Services == nil {
+ return errors.New("should add at least 1 service")
+ }
+
+ if len(c.Services) == 0 {
+ return errors.New("should add initialized config")
+ }
+ }
+
return nil
}