summaryrefslogtreecommitdiff
path: root/service/reload/config.go
blob: f684a227a85fd6d3f7d2ed459b8590b8c5ec76c3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package reload

import (
	"github.com/spiral/roadrunner"
	"github.com/spiral/roadrunner/service"
)

// Config is a Reload configuration point.
type Config struct {
	// Enable or disable Reload extension, default disable.
	Enabled bool

	// Watch is general pattern of files to watch. It will be applied to every directory in project
	Watch []string

	// Services is set of services which would be reloaded in case of FS changes
	Services map[string]ServiceConfig
}

type ServiceConfig struct {
	// Recursive is options to use nested files from root folder
	Recursive bool
	// Patterns is per-service specific files to watch
	Patterns []string
	// Dirs is per-service specific dirs which will be combined with Patterns
	Dirs []string
	// Ignore is set of files which would not be watched
	Ignore []string

	// service is a link to service to restart
	service *roadrunner.Controllable
}

// Hydrate must populate Config values using given Config source. Must return error if Config is not valid.
func (c *Config) Hydrate(cfg service.Config) error {
	if err := cfg.Unmarshal(c); err != nil {
		return err
	}
	return nil
}

// InitDefaults sets missing values to their default values.
func (c *Config) InitDefaults() error {
	//c.Interval = time.Second

	return nil
}