13493: Test DELETE and PUT methods.
[arvados.git] / services / keep-balance / main.go
index fe4a8c41c572932853076a8b0465d5e0bee01049..90235cbf3188d91bc274412ddd5522dc639fa812 100644 (file)
@@ -9,6 +9,7 @@ import (
        "flag"
        "fmt"
        "log"
+       "net/http"
        "os"
        "os/signal"
        "syscall"
@@ -16,9 +17,10 @@ import (
 
        "git.curoverse.com/arvados.git/sdk/go/arvados"
        "git.curoverse.com/arvados.git/sdk/go/config"
-       arvadosVersion "git.curoverse.com/arvados.git/sdk/go/version"
 )
 
+var version = "dev"
+
 const defaultConfigPath = "/etc/arvados/keep-balance/keep-balance.yml"
 
 // Config specifies site configuration, like API credentials and the
@@ -44,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
@@ -93,8 +98,8 @@ func main() {
 
        // Print version information if requested
        if *getVersion {
-               fmt.Printf("Version: %s\n", arvadosVersion.GetVersion())
-               os.Exit(0)
+               fmt.Printf("keep-balance %s\n", version)
+               return
        }
 
        mustReadConfig(&cfg, *configPath)
@@ -106,7 +111,15 @@ func main() {
                log.Fatal(config.DumpAndExit(cfg))
        }
 
-       log.Printf("keep-balance %q started", arvadosVersion.GetVersion())
+       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