X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/cc94954f69ed2d26451bae6610b38de260d2252f..dd481ab3359f1b360a22d03c09d8035ef5db1f38:/services/crunchstat/crunchstat.go diff --git a/services/crunchstat/crunchstat.go b/services/crunchstat/crunchstat.go index e71989afb8..ad433bb3b5 100644 --- a/services/crunchstat/crunchstat.go +++ b/services/crunchstat/crunchstat.go @@ -1,8 +1,13 @@ +// Copyright (C) The Arvados Authors. All rights reserved. +// +// SPDX-License-Identifier: AGPL-3.0 + package main import ( "bufio" "flag" + "fmt" "io" "log" "os" @@ -19,6 +24,7 @@ const MaxLogLine = 1 << 14 // Child stderr lines >16KiB will be split var ( signalOnDeadPPID int = 15 ppidCheckInterval = time.Second + version = "dev" ) func main() { @@ -32,9 +38,18 @@ func main() { flag.IntVar(&signalOnDeadPPID, "signal-on-dead-ppid", signalOnDeadPPID, "Signal to send child if crunchstat's parent process disappears (0 to disable)") flag.DurationVar(&ppidCheckInterval, "ppid-check-interval", ppidCheckInterval, "Time between checks for parent process disappearance") pollMsec := flag.Int64("poll", 1000, "Reporting interval, in milliseconds") + getVersion := flag.Bool("version", false, "Print version information and exit.") flag.Parse() + // Print version information if requested + if *getVersion { + fmt.Printf("crunchstat %s\n", version) + return + } + + reporter.Logger.Printf("crunchstat %s started", version) + if reporter.CgroupRoot == "" { reporter.Logger.Fatal("error: must provide -cgroup-root") } else if signalOnDeadPPID < 0 { @@ -113,7 +128,7 @@ func runCommand(argv []string, logger *log.Logger) error { func sendSignalOnDeadPPID(intvl time.Duration, signum, ppidOrig int, cmd *exec.Cmd, logger *log.Logger) { ticker := time.NewTicker(intvl) - for _ = range ticker.C { + for range ticker.C { ppid := os.Getppid() if ppid == ppidOrig { continue