Skip to content

Commit

Permalink
Enable router debug. Make logs json formatted for absolute timestamps.
Browse files Browse the repository at this point in the history
  • Loading branch information
plorenz committed May 14, 2024
1 parent 2d09da8 commit 03b54d6
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 8 deletions.
12 changes: 9 additions & 3 deletions zititest/models/smoke/smoketest.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,9 @@ var Model = &model.Model{
Components: model.Components{
"router-east-1": {
Scope: model.Scope{Tags: model.Tags{"edge-router", "terminator", "tunneler", "client"}},
Type: &zitilab.RouterType{},
Type: &zitilab.RouterType{
Debug: true,
},
},
"zcat": {
Scope: model.Scope{Tags: model.Tags{"sdk-app", "client"}},
Expand All @@ -167,7 +169,9 @@ var Model = &model.Model{
Components: model.Components{
"router-east-2": {
Scope: model.Scope{Tags: model.Tags{"edge-router", "initiator"}},
Type: &zitilab.RouterType{},
Type: &zitilab.RouterType{
Debug: true,
},
},
},
},
Expand Down Expand Up @@ -211,7 +215,9 @@ var Model = &model.Model{
Components: model.Components{
"router-west": {
Scope: model.Scope{Tags: model.Tags{"edge-router", "tunneler", "host", "ert-host"}},
Type: &zitilab.RouterType{},
Type: &zitilab.RouterType{
Debug: true,
},
},
"echo-server": {
Scope: model.Scope{Tags: model.Tags{"sdk-app", "service"}},
Expand Down
6 changes: 3 additions & 3 deletions zititest/zitilab/component_common.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func getZitiProcessFilter(c *model.Component, zitiType string) func(string) bool
}
}

func startZitiComponent(c *model.Component, zitiType string, version string, configName string) error {
func startZitiComponent(c *model.Component, zitiType string, version string, configName string, extraArgs string) error {
user := c.GetHost().GetSshUser()

binaryPath := GetZitiBinaryPath(c, version)
Expand All @@ -47,8 +47,8 @@ func startZitiComponent(c *model.Component, zitiType string, version string, con
useSudo = "sudo"
}

serviceCmd := fmt.Sprintf("nohup %s %s %s run --cli-agent-alias %s --log-formatter pfxlog %s > %s 2>&1 &",
useSudo, binaryPath, zitiType, c.Id, configPath, logsPath)
serviceCmd := fmt.Sprintf("nohup %s %s %s run %s --cli-agent-alias %s --log-formatter json %s > %s 2>&1 &",
useSudo, binaryPath, zitiType, extraArgs, c.Id, configPath, logsPath)

if quiet, _ := c.GetBoolVariable("quiet_startup"); !quiet {
logrus.Info(serviceCmd)
Expand Down
7 changes: 6 additions & 1 deletion zititest/zitilab/component_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ type ControllerType struct {
Version string
LocalPath string
DNSNames []string
Debug bool
}

func (self *ControllerType) Label() string {
Expand Down Expand Up @@ -121,7 +122,11 @@ func (self *ControllerType) Start(r model.Run, c *model.Component) error {
fmt.Printf("controller %s already started\n", c.Id)
return nil
}
return startZitiComponent(c, "controller", self.Version, self.getConfigName(c))
extraArgs := ""
if self.Debug {
extraArgs = " -v "
}
return startZitiComponent(c, "controller", self.Version, self.getConfigName(c), extraArgs)
}

func (self *ControllerType) Stop(_ model.Run, c *model.Component) error {
Expand Down
7 changes: 6 additions & 1 deletion zititest/zitilab/component_router.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ type RouterType struct {
ConfigName string
Version string
LocalPath string
Debug bool
}

func (self *RouterType) Label() string {
Expand Down Expand Up @@ -128,7 +129,11 @@ func (self *RouterType) Start(r model.Run, c *model.Component) error {
fmt.Printf("router %s already started\n", c.Id)
return nil
}
return startZitiComponent(c, "router", self.Version, self.GetConfigName(c))
extraArgs := ""
if self.Debug {
extraArgs = " -v "
}
return startZitiComponent(c, "router", self.Version, self.GetConfigName(c), extraArgs)
}

func (self *RouterType) Stop(run model.Run, c *model.Component) error {
Expand Down

0 comments on commit 03b54d6

Please sign in to comment.