X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/0561bd0c3c07257fd58ded6c7cfa5feeae97af57..38c4ce8bd5aefed6784d457ed3caf28f279d6de4:/services/keep-balance/main.go diff --git a/services/keep-balance/main.go b/services/keep-balance/main.go index 8a938ccf53..90235cbf31 100644 --- a/services/keep-balance/main.go +++ b/services/keep-balance/main.go @@ -7,7 +7,9 @@ package main import ( "encoding/json" "flag" + "fmt" "log" + "net/http" "os" "os/signal" "syscall" @@ -17,6 +19,8 @@ import ( "git.curoverse.com/arvados.git/sdk/go/config" ) +var version = "dev" + const defaultConfigPath = "/etc/arvados/keep-balance/keep-balance.yml" // Config specifies site configuration, like API credentials and the @@ -42,6 +46,9 @@ type Config struct { // more memory, but can reduce store-and-forward latency when // fetching pages) CollectionBuffers int + + // Timeout for outgoing http request/response cycle. + RequestTimeout arvados.Duration } // RunOptions controls runtime behavior. The flags/options that belong @@ -85,9 +92,16 @@ func main() { dumpConfig := flag.Bool("dump-config", false, "write current configuration to stdout and exit") dumpFlag := flag.Bool("dump", false, "dump details for each block to stdout") debugFlag := flag.Bool("debug", false, "enable debug messages") + getVersion := flag.Bool("version", false, "Print version information and exit.") flag.Usage = usage flag.Parse() + // Print version information if requested + if *getVersion { + fmt.Printf("keep-balance %s\n", version) + return + } + mustReadConfig(&cfg, *configPath) if *serviceListPath != "" { mustReadConfig(&cfg.KeepServiceList, *serviceListPath) @@ -97,6 +111,16 @@ func main() { log.Fatal(config.DumpAndExit(cfg)) } + to := time.Duration(cfg.RequestTimeout) + if to == 0 { + to = 30 * time.Minute + } + arvados.DefaultSecureClient.Timeout = to + arvados.InsecureHTTPClient.Timeout = to + http.DefaultClient.Timeout = to + + log.Printf("keep-balance %s started", version) + if *debugFlag { debugf = log.Printf if j, err := json.Marshal(cfg); err != nil {