Skip to content

Commit

Permalink
chore: add port to config
Browse files Browse the repository at this point in the history
  • Loading branch information
kashalls committed Apr 2, 2024
1 parent 727aa60 commit c7518bd
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions config.yaml.example
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
# yaml-language-server: $schema=https://raw.githubusercontent.com/kashalls/kromgo/main/config.schema.json
debug: false
port: 8080
metrics:
- name: node_cpu_usage
query: "round(cluster:node_cpu:ratio_rate5m * 100, 0.1)"
Expand Down
6 changes: 5 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ type Metric struct {

type Config struct {
Debug bool `yaml:"debug,omitempty" json:"debug,omitempty"`
Port string `yaml:"port,omitempty" json:"port,omitempty"`
Prometheus string `yaml:"prometheus,omitempty" json:"prometheus,omitempty"`
Metrics []Metric `yaml:"metrics" json:"metrics"`
}
Expand Down Expand Up @@ -247,7 +248,10 @@ func main() {
// Determine the HTTP server port
port := os.Getenv("PORT")
if port == "" {
port = "8080" // Default port
port = config.Port
if port == "" {
port = "8080"
}
}

// Start the HTTP server
Expand Down

0 comments on commit c7518bd

Please sign in to comment.