|
@@ -3,25 +3,25 @@ package main
|
|
|
import (
|
|
import (
|
|
|
log "github.com/sirupsen/logrus"
|
|
log "github.com/sirupsen/logrus"
|
|
|
|
|
|
|
|
- restApi "github.com/jamesread/OliveTin/pkg/restApi"
|
|
|
|
|
- grpcApi "github.com/jamesread/OliveTin/pkg/grpcApi"
|
|
|
|
|
- webuiServer "github.com/jamesread/OliveTin/pkg/webuiServer"
|
|
|
|
|
|
|
+ grpcapi "github.com/jamesread/OliveTin/internal/grpcapi"
|
|
|
|
|
+ restapi "github.com/jamesread/OliveTin/internal/restapi"
|
|
|
|
|
+ webuiServer "github.com/jamesread/OliveTin/internal/webuiServer"
|
|
|
|
|
|
|
|
- config "github.com/jamesread/OliveTin/pkg/config"
|
|
|
|
|
- executor "github.com/jamesread/OliveTin/pkg/executor"
|
|
|
|
|
|
|
+ config "github.com/jamesread/OliveTin/internal/config"
|
|
|
|
|
+ executor "github.com/jamesread/OliveTin/internal/executor"
|
|
|
"github.com/spf13/viper"
|
|
"github.com/spf13/viper"
|
|
|
"os"
|
|
"os"
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
var (
|
|
var (
|
|
|
- cfg *config.Config;
|
|
|
|
|
|
|
+ cfg *config.Config
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
func init() {
|
|
func init() {
|
|
|
- log.Info("OliveTin initializing");
|
|
|
|
|
|
|
+ log.Info("OliveTin initializing")
|
|
|
log.SetLevel(log.DebugLevel) // Default to debug, to catch cfg issues
|
|
log.SetLevel(log.DebugLevel) // Default to debug, to catch cfg issues
|
|
|
|
|
|
|
|
- viper.AutomaticEnv();
|
|
|
|
|
|
|
+ viper.AutomaticEnv()
|
|
|
viper.SetConfigName("config.yaml")
|
|
viper.SetConfigName("config.yaml")
|
|
|
viper.SetConfigType("yaml")
|
|
viper.SetConfigType("yaml")
|
|
|
viper.AddConfigPath(".")
|
|
viper.AddConfigPath(".")
|
|
@@ -29,35 +29,35 @@ func init() {
|
|
|
viper.AddConfigPath("/etc/OliveTin/")
|
|
viper.AddConfigPath("/etc/OliveTin/")
|
|
|
|
|
|
|
|
if err := viper.ReadInConfig(); err != nil {
|
|
if err := viper.ReadInConfig(); err != nil {
|
|
|
- log.Errorf("Config file error at startup. %s", err);
|
|
|
|
|
- os.Exit(1);
|
|
|
|
|
- };
|
|
|
|
|
|
|
+ log.Errorf("Config file error at startup. %s", err)
|
|
|
|
|
+ os.Exit(1)
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- cfg = config.DefaultConfig();
|
|
|
|
|
|
|
+ cfg = config.DefaultConfig()
|
|
|
|
|
|
|
|
if err := viper.UnmarshalExact(cfg); err != nil {
|
|
if err := viper.UnmarshalExact(cfg); err != nil {
|
|
|
log.Errorf("Config unmarshal error %+v", err)
|
|
log.Errorf("Config unmarshal error %+v", err)
|
|
|
- os.Exit(1);
|
|
|
|
|
|
|
+ os.Exit(1)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
log.SetLevel(cfg.GetLogLevel())
|
|
log.SetLevel(cfg.GetLogLevel())
|
|
|
|
|
|
|
|
- viper.WatchConfig();
|
|
|
|
|
|
|
+ viper.WatchConfig()
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
func main() {
|
|
func main() {
|
|
|
- log.WithFields(log.Fields {
|
|
|
|
|
|
|
+ log.WithFields(log.Fields{
|
|
|
"listenAddressGrpcActions": cfg.ListenAddressGrpcActions,
|
|
"listenAddressGrpcActions": cfg.ListenAddressGrpcActions,
|
|
|
"listenAddressRestActions": cfg.ListenAddressRestActions,
|
|
"listenAddressRestActions": cfg.ListenAddressRestActions,
|
|
|
- "listenAddressWebUi": cfg.ListenAddressWebUi,
|
|
|
|
|
- }).Info("OliveTin started");
|
|
|
|
|
|
|
+ "listenAddressWebUI": cfg.ListenAddressWebUI,
|
|
|
|
|
+ }).Info("OliveTin started")
|
|
|
|
|
|
|
|
log.Debugf("%+v", cfg)
|
|
log.Debugf("%+v", cfg)
|
|
|
|
|
|
|
|
- executor.Cfg = cfg;
|
|
|
|
|
|
|
+ executor.Cfg = cfg
|
|
|
|
|
|
|
|
- go grpcApi.Start(cfg.ListenAddressGrpcActions, cfg)
|
|
|
|
|
- go restApi.Start(cfg.ListenAddressRestActions, cfg.ListenAddressGrpcActions, cfg)
|
|
|
|
|
|
|
+ go grpcapi.Start(cfg.ListenAddressGrpcActions, cfg)
|
|
|
|
|
+ go restapi.Start(cfg.ListenAddressRestActions, cfg.ListenAddressGrpcActions, cfg)
|
|
|
|
|
|
|
|
- webuiServer.Start(cfg.ListenAddressWebUi, cfg.ListenAddressRestActions)
|
|
|
|
|
|
|
+ webuiServer.Start(cfg.ListenAddressWebUI, cfg.ListenAddressRestActions)
|
|
|
}
|
|
}
|