initial import for nested configs
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
parent
82824cdfcc
commit
4c32535bfa
@ -3,8 +3,10 @@ package main
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"io/fs"
|
||||
"os"
|
||||
"os/signal"
|
||||
"path/filepath"
|
||||
"time"
|
||||
|
||||
openapi_v3 "github.com/google/gnostic/openapiv3"
|
||||
@ -73,6 +75,27 @@ func main() {
|
||||
l.Fatal(ctx, "failed to open config", err)
|
||||
}
|
||||
|
||||
if cfg.App.ChecksDir != "" {
|
||||
if !filepath.IsAbs(cfg.App.ChecksDir) {
|
||||
dir, _ := os.Getwd()
|
||||
cfg.App.ChecksDir = filepath.Clean(filepath.Join(dir, cfg.App.ChecksDir))
|
||||
}
|
||||
|
||||
err = filepath.WalkDir(cfg.App.ChecksDir, func(path string, info fs.DirEntry, err error) error {
|
||||
if err != nil {
|
||||
// fmt.Printf("prevent panic by handling failure accessing a path %q: %v\n", path, err)
|
||||
return err
|
||||
}
|
||||
if info.IsDir() {
|
||||
return nil
|
||||
}
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
l.Fatal(ctx, fmt.Sprintf("error loading config: %s", cfg.App.ChecksDir), err)
|
||||
}
|
||||
}
|
||||
|
||||
if !cfg.App.MultiUser {
|
||||
m.Init(
|
||||
meter.WriteFDMetrics(true),
|
||||
@ -153,7 +176,7 @@ func main() {
|
||||
}
|
||||
clients["http"] = hcli
|
||||
|
||||
for _, check := range cfg.Checks {
|
||||
for _, check := range cfg.App.Checks {
|
||||
l.Info(ctx, fmt.Sprintf("check %#+v", check))
|
||||
if !check.Active {
|
||||
continue
|
||||
|
@ -8,7 +8,9 @@ import (
|
||||
)
|
||||
|
||||
type AppConfig struct {
|
||||
MultiUser bool `json:"multi_user,omitempty" yaml:"multi_user,omitempty"`
|
||||
ChecksDir string `json:"checks_dir,omitempty" yaml:"checks_dir,omitempty"`
|
||||
Checks []*CheckConfig `json:"checks,omitempty" yaml:"checks,omitempty"`
|
||||
MultiUser bool `json:"multi_user,omitempty" yaml:"multi_user,omitempty"`
|
||||
}
|
||||
|
||||
type MeterConfig struct {
|
||||
@ -17,9 +19,8 @@ type MeterConfig struct {
|
||||
}
|
||||
|
||||
type Config struct {
|
||||
App *AppConfig `json:"app,omitempty" yaml:"app,omitempty"`
|
||||
Meter *MeterConfig `json:"meter,omitempty" yaml:"meter,omitempty"`
|
||||
Checks []*CheckConfig `json:"checks,omitempty" yaml:"checks,omitempty"`
|
||||
App *AppConfig `json:"app,omitempty" yaml:"app,omitempty"`
|
||||
Meter *MeterConfig `json:"meter,omitempty" yaml:"meter,omitempty"`
|
||||
}
|
||||
|
||||
type CheckConfig struct {
|
||||
|
@ -3,8 +3,8 @@
|
||||
package grpcconn
|
||||
|
||||
import (
|
||||
"github.com/emicklei/proto"
|
||||
"github.com/jhump/protoreflect/desc"
|
||||
"google.golang.org/protobuf/proto"
|
||||
)
|
||||
|
||||
var protoSets = map[string]*desc.FileDescriptor
|
||||
|
Loading…
x
Reference in New Issue
Block a user