diff options
Diffstat (limited to 'client/go/internal/admin/vespa-wrapper/startcbinary/startcbinary.go')
-rw-r--r-- | client/go/internal/admin/vespa-wrapper/startcbinary/startcbinary.go | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/client/go/internal/admin/vespa-wrapper/startcbinary/startcbinary.go b/client/go/internal/admin/vespa-wrapper/startcbinary/startcbinary.go new file mode 100644 index 00000000000..f5e58e59808 --- /dev/null +++ b/client/go/internal/admin/vespa-wrapper/startcbinary/startcbinary.go @@ -0,0 +1,47 @@ +// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Author: arnej + +package startcbinary + +import ( + "fmt" + "os" + + "github.com/vespa-engine/vespa/client/go/internal/admin/envvars" + "github.com/vespa-engine/vespa/client/go/internal/util" +) + +func startCbinary(spec *ProgSpec) int { + spec.configureCommonEnv() + spec.configurePath() + spec.configureTuning() + spec.configureValgrind() + spec.configureNumaCtl() + spec.configureHugePages() + spec.configureUseMadvise() + spec.configureVespaMalloc() + err := spec.run() + if err != nil { + fmt.Fprintln(os.Stderr, err) + return 1 + } else { + return 0 + } +} + +func (spec *ProgSpec) run() error { + prog := spec.Program + args := spec.Args + if spec.shouldUseValgrind { + args = spec.prependValgrind(args) + prog = spec.valgrindBinary() + } else if spec.shouldUseNumaCtl { + args = spec.prependNumaCtl(args) + prog = spec.numaCtlBinary() + } + if spec.shouldUseVespaMalloc { + spec.setenv(envvars.LD_PRELOAD, spec.vespaMallocPreload) + } + envv := spec.effectiveEnv() + return util.Execvpe(prog, args, envv) +} |