X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/436f5c768dbc97135490b6477efd1ff0482a9dda..524c20020594ba67a2a822eccb632f8a5f5dc3ce:/services/keepstore/keepstore.go diff --git a/services/keepstore/keepstore.go b/services/keepstore/keepstore.go index 9033de8117..c742752017 100644 --- a/services/keepstore/keepstore.go +++ b/services/keepstore/keepstore.go @@ -1,3 +1,7 @@ +// Copyright (C) The Arvados Authors. All rights reserved. +// +// SPDX-License-Identifier: AGPL-3.0 + package main import ( @@ -12,12 +16,12 @@ import ( "git.curoverse.com/arvados.git/sdk/go/arvadosclient" "git.curoverse.com/arvados.git/sdk/go/config" - "git.curoverse.com/arvados.git/sdk/go/httpserver" "git.curoverse.com/arvados.git/sdk/go/keepclient" - log "github.com/Sirupsen/logrus" "github.com/coreos/go-systemd/daemon" ) +var version = "dev" + // A Keep "block" is 64MB. const BlockSize = 64 * 1024 * 1024 @@ -85,6 +89,7 @@ func main() { deprecated.beforeFlagParse(theConfig) dumpConfig := flag.Bool("dump-config", false, "write current configuration to stdout and exit (useful for migrating from command line flags to config file)") + getVersion := flag.Bool("version", false, "Print version information and exit.") defaultConfigPath := "/etc/arvados/keepstore/keepstore.yml" var configPath string @@ -96,6 +101,12 @@ func main() { flag.Usage = usage flag.Parse() + // Print version information if requested + if *getVersion { + fmt.Printf("keepstore %s\n", version) + return + } + deprecated.afterFlagParse(theConfig) err := config.LoadFile(theConfig, configPath) @@ -107,6 +118,8 @@ func main() { log.Fatal(config.DumpAndExit(theConfig)) } + log.Printf("keepstore %s started", version) + err = theConfig.Start() if err != nil { log.Fatal(err) @@ -143,11 +156,8 @@ func main() { // Start a round-robin VolumeManager with the volumes we have found. KeepVM = MakeRRVolumeManager(theConfig.Volumes) - // Middleware stack: logger, MaxRequests limiter, method handlers + // Middleware/handler stack router := MakeRESTRouter() - limiter := httpserver.NewRequestLimiter(theConfig.MaxRequests, router) - router.limiter = limiter - http.Handle("/", &LoggingRESTRouter{router: limiter}) // Set up a TCP listener. listener, err := net.Listen("tcp", theConfig.Listen) @@ -155,20 +165,23 @@ func main() { log.Fatal(err) } - // Initialize Pull queue and worker + // Initialize keepclient for pull workers keepClient := &keepclient.KeepClient{ Arvados: &arvadosclient.ArvadosClient{}, Want_replicas: 1, - Client: &http.Client{}, } - // Initialize the pullq and worker + // Initialize the pullq and workers pullq = NewWorkQueue() - go RunPullWorker(pullq, keepClient) + for i := 0; i < 1 || i < theConfig.PullWorkers; i++ { + go RunPullWorker(pullq, keepClient) + } - // Initialize the trashq and worker + // Initialize the trashq and workers trashq = NewWorkQueue() - go RunTrashWorker(trashq) + for i := 0; i < 1 || i < theConfig.TrashWorkers; i++ { + go RunTrashWorker(trashq) + } // Start emptyTrash goroutine doneEmptyingTrash := make(chan bool) @@ -190,7 +203,7 @@ func main() { log.Printf("Error notifying init daemon: %v", err) } log.Println("listening at", listener.Addr()) - srv := &http.Server{} + srv := &http.Server{Handler: router} srv.Serve(listener) }