Migrate a bunch of stuff around to prep for worker command (#2)
Right now it's essentially a copy; it needs some updating, integration into dev, and so on.
This commit is contained in:
1 parent
c2d385d851
commit
1645c3106e
18 files changed
+1200
-157
No files matched your search
@@ -54,7 +54,7 @@ Usage: watchtower controller [options]
|
||||
|
||||
Start a controller with a configuration file:
|
||||
|
||||
$ watchtower controller -config=/etc/controller/config.hcl
|
||||
$ watchtower controller -config=/etc/watchtower/controller.hcl
|
||||
|
||||
For a full list of examples, please see the documentation.
|
||||
|
||||
@@ -147,15 +147,15 @@ func (c *Command) Run(args []string) int {
|
||||
return result
|
||||
}
|
||||
|
||||
if memProfilerEnabled {
|
||||
c.startMemProfiler()
|
||||
}
|
||||
|
||||
if err := c.SetupLogging(c.flagLogLevel, c.flagLogFormat, c.Config.LogLevel, c.Config.LogFormat); err != nil {
|
||||
c.UI.Error(err.Error())
|
||||
return 1
|
||||
}
|
||||
|
||||
if memProfilerEnabled {
|
||||
base.StartMemProfiler(c.Logger)
|
||||
}
|
||||
|
||||
if err := c.SetupMetrics(c.UI, c.Config.Telemetry); err != nil {
|
||||
c.UI.Error(err.Error())
|
||||
return 1
|
||||
@@ -259,21 +259,21 @@ func (c *Command) ParseFlagsAndConfig(args []string) int {
|
||||
|
||||
func (c *Command) Start() int {
|
||||
// Instantiate the wait group
|
||||
controllerConfig := &controller.Config{
|
||||
conf := &controller.Config{
|
||||
RawConfig: c.Config,
|
||||
Server: c.Server,
|
||||
}
|
||||
|
||||
// Initialize the core
|
||||
controller, err := controller.New(controllerConfig)
|
||||
ctlr, err := controller.New(conf)
|
||||
if err != nil {
|
||||
c.UI.Error(fmt.Sprintf("Error initializing controller: %w", err))
|
||||
return 1
|
||||
}
|
||||
|
||||
if err := controller.Start(); err != nil {
|
||||
if err := ctlr.Start(); err != nil {
|
||||
c.UI.Error(fmt.Sprint("Error starting controller: %w", err))
|
||||
if err := controller.Shutdown(); err != nil {
|
||||
if err := ctlr.Shutdown(); err != nil {
|
||||
c.UI.Error(fmt.Sprintf("Error with controller shutdown: %w", err))
|
||||
}
|
||||
return 1
|
||||
@@ -287,7 +287,7 @@ func (c *Command) Start() int {
|
||||
case <-c.ShutdownCh:
|
||||
c.UI.Output("==> Watchtower controller shutdown triggered")
|
||||
|
||||
if err := controller.Shutdown(); err != nil {
|
||||
if err := ctlr.Shutdown(); err != nil {
|
||||
c.UI.Error(fmt.Sprintf("Error with controller shutdown: %w", err))
|
||||
}
|
||||
|
||||
@@ -337,7 +337,7 @@ func (c *Command) Start() int {
|
||||
c.Logger.Error("unknown log level found on reload", "level", newConf.LogLevel)
|
||||
goto RUNRELOADFUNCS
|
||||
}
|
||||
controller.SetLogLevel(level)
|
||||
ctlr.SetLogLevel(level)
|
||||
}
|
||||
|
||||
RUNRELOADFUNCS:
|
||||
|
||||
Reference in new issue
Block a user