Skip to content

Commit

Permalink
Add SSL and dev mode flags to agent
Browse files Browse the repository at this point in the history
  • Loading branch information
Codycody31 committed Feb 1, 2024
1 parent df527a4 commit e2bf51a
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
12 changes: 12 additions & 0 deletions agent/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ var flags = []cli.Flag{
Usage: "server address",
Value: "localhost:5000",
},
&cli.BoolFlag{
EnvVars: []string{"ECHOES_SSL"},
Name: "ssl",
Usage: "enable ssl",
Value: false,
},
&cli.StringFlag{
EnvVars: []string{"ECHOES_AGENT_SECRET"},
Name: "secret",
Expand All @@ -51,4 +57,10 @@ var flags = []cli.Flag{
Usage: "healthcheck endpoint address",
Value: ":5000",
},
&cli.BoolFlag{
EnvVars: []string{"ECHOES_DEV_MODE"},
Name: "dev-mode",
Usage: "enable dev mode",
Value: false,
},
}
16 changes: 15 additions & 1 deletion agent/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,21 @@ func runAgent(context *cli.Context) error {
if strings.HasPrefix(healthcheckAddress, ":") {
healthcheckAddress = "localhost" + healthcheckAddress
}
if !checkServerHealth("http://" + healthcheckAddress + "/general/healthcheck") {

// Build the protocol
protocol := "http"
if context.Bool("ssl") {
protocol = "https"
}

// Build the healthcheck URL
if context.Bool("dev-mode") {
healthcheckAddress = protocol + "://" + healthcheckAddress + "/general/healthcheck"
} else {
healthcheckAddress = protocol + "://" + healthcheckAddress + "/api/general/healthcheck"
}

if !checkServerHealth(healthcheckAddress) {
log.Error("agent", "Server is not healthy")
return nil
}
Expand Down

0 comments on commit e2bf51a

Please sign in to comment.