metrics: handle equal to separated config flag (#596)

* metrics: handle  based config path

* internal/cli/server: add more context to logs

* use space separated flag and value in bor.service
This commit is contained in:
Manav Darji 2022-11-24 19:42:32 +05:30 committed by GitHub
parent 58a63147f2
commit 137fb19d2a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 12 additions and 3 deletions

View file

@ -6,7 +6,7 @@
[Service] [Service]
Restart=on-failure Restart=on-failure
RestartSec=5s RestartSec=5s
ExecStart=/usr/local/bin/bor server -config="/var/lib/bor/config.toml" ExecStart=/usr/local/bin/bor server -config "/var/lib/bor/config.toml"
Type=simple Type=simple
User=bor User=bor
KillSignal=SIGINT KillSignal=SIGINT

View file

@ -235,7 +235,13 @@ func (s *Server) Stop() {
func (s *Server) setupMetrics(config *TelemetryConfig, serviceName string) error { func (s *Server) setupMetrics(config *TelemetryConfig, serviceName string) error {
// Check the global metrics if they're matching with the provided config // Check the global metrics if they're matching with the provided config
if metrics.Enabled != config.Enabled || metrics.EnabledExpensive != config.Expensive { if metrics.Enabled != config.Enabled || metrics.EnabledExpensive != config.Expensive {
log.Warn("Metric misconfiguration, some of them might not be visible") log.Warn(
"Metric misconfiguration, some of them might not be visible",
"metrics", metrics.Enabled,
"config.metrics", config.Enabled,
"expensive", metrics.EnabledExpensive,
"config.expensive", config.Expensive,
)
} }
// Update the values anyways (for services which don't need immediate attention) // Update the values anyways (for services which don't need immediate attention)

View file

@ -49,6 +49,9 @@ func init() {
// check for existence of `config` flag // check for existence of `config` flag
if flag == configFlag && i < len(os.Args)-1 { if flag == configFlag && i < len(os.Args)-1 {
configFile = strings.TrimLeft(os.Args[i+1], "-") // find the value of flag configFile = strings.TrimLeft(os.Args[i+1], "-") // find the value of flag
} else if len(flag) > 6 && flag[:6] == configFlag {
// Checks for `=` separated flag (e.g. config=path)
configFile = strings.TrimLeft(flag[6:], "=")
} }
for _, enabler := range enablerFlags { for _, enabler := range enablerFlags {

View file

@ -6,7 +6,7 @@
[Service] [Service]
Restart=on-failure Restart=on-failure
RestartSec=5s RestartSec=5s
ExecStart=/usr/bin/bor server -config="/var/lib/bor/config.toml" ExecStart=/usr/bin/bor server -config "/var/lib/bor/config.toml"
Type=simple Type=simple
KillSignal=SIGINT KillSignal=SIGINT
User=bor User=bor