X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/f0e6212bbe6e34f6ac4e928a236e77cca852895d..db5107dca09b786374f06a35abb51ffc3f032abd:/services/health/main.go diff --git a/services/health/main.go b/services/health/main.go index 3e089fa5a2..1d2ec47a6a 100644 --- a/services/health/main.go +++ b/services/health/main.go @@ -1,6 +1,12 @@ +// Copyright (C) The Arvados Authors. All rights reserved. +// +// SPDX-License-Identifier: AGPL-3.0 + package main import ( + "flag" + "fmt" "net/http" "git.curoverse.com/arvados.git/sdk/go/arvados" @@ -9,11 +15,25 @@ import ( log "github.com/Sirupsen/logrus" ) +var version = "dev" + func main() { + configFile := flag.String("config", arvados.DefaultConfigFile, "`path` to arvados configuration file") + getVersion := flag.Bool("version", false, "Print version information and exit.") + flag.Parse() + + // Print version information if requested + if *getVersion { + fmt.Printf("arvados-health %s\n", version) + return + } + log.SetFormatter(&log.JSONFormatter{ TimestampFormat: "2006-01-02T15:04:05.000000000Z07:00", }) - cfg, err := arvados.GetConfig() + log.Printf("arvados-health %s started", version) + + cfg, err := arvados.GetConfig(*configFile) if err != nil { log.Fatal(err) } @@ -21,16 +41,23 @@ func main() { if err != nil { log.Fatal(err) } - nodeCfg, err := clusterCfg.GetThisSystemNode() + nodeCfg, err := clusterCfg.GetNodeProfile("") if err != nil { log.Fatal(err) } + log := log.WithField("Service", "Health") srv := &httpserver.Server{ Addr: nodeCfg.Health.Listen, Server: http.Server{ Handler: &health.Aggregator{ Config: cfg, + Log: func(req *http.Request, err error) { + log.WithField("RemoteAddr", req.RemoteAddr). + WithField("Path", req.URL.Path). + WithError(err). + Info("HTTP request") + }, }, }, }