summaryrefslogtreecommitdiff
path: root/plugins/service/config.go
diff options
context:
space:
mode:
authorValery Piashchynski <[email protected]>2021-04-18 17:31:52 +0300
committerValery Piashchynski <[email protected]>2021-04-18 17:31:52 +0300
commit4e6dfc00c5619c4e749602d345fd2829ab0a3f07 (patch)
tree12b4ce7644b02b6e76cfa46e8c80d54690d6e0dc /plugins/service/config.go
parent15b7a9a0fc074531f9b46bb87fb35819e248a58c (diff)
- Draft implementation of the service plugin
Diffstat (limited to 'plugins/service/config.go')
-rw-r--r--plugins/service/config.go34
1 files changed, 34 insertions, 0 deletions
diff --git a/plugins/service/config.go b/plugins/service/config.go
new file mode 100644
index 00000000..b1099e06
--- /dev/null
+++ b/plugins/service/config.go
@@ -0,0 +1,34 @@
+package service
+
+import "time"
+
+// Service represents particular service configuration
+type Service struct {
+ Command string `mapstructure:"command"`
+ ProcessNum int `mapstructure:"process_num"`
+ ExecTimeout time.Duration `mapstructure:"exec_timeout"`
+ RestartAfterExit bool `mapstructure:"restart_after_exit"`
+ RestartDelay time.Duration `mapstructure:"restart_delay"`
+}
+
+// Config for the services
+type Config struct {
+ Services map[string]Service `mapstructure:"service"`
+}
+
+func (c *Config) InitDefault() {
+ if len(c.Services) > 0 {
+ for k, v := range c.Services {
+ if v.ProcessNum == 0 {
+ val := c.Services[k]
+ val.ProcessNum = 1
+ c.Services[k] = val
+ }
+ if v.RestartDelay == 0 {
+ val := c.Services[k]
+ val.RestartDelay = time.Minute
+ c.Services[k] = val
+ }
+ }
+ }
+}