diff options
author | Arne Juul <arnej@yahooinc.com> | 2022-11-16 12:41:18 +0000 |
---|---|---|
committer | Arne Juul <arnej@yahooinc.com> | 2022-11-18 13:15:13 +0000 |
commit | 9856a174e70177a3df3f9b15f5b8c193e0e4a395 (patch) | |
tree | 82ae64f026006488e6bfa48487caee9cf141a6a8 /client/go/script-utils/standalone/start.go | |
parent | add8c45ce4753256356efd832a8a34ddbfaa4287 (diff) |
add start script for standalone containers
Diffstat (limited to 'client/go/script-utils/standalone/start.go')
-rw-r--r-- | client/go/script-utils/standalone/start.go | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/client/go/script-utils/standalone/start.go b/client/go/script-utils/standalone/start.go new file mode 100644 index 00000000000..7b929730f5a --- /dev/null +++ b/client/go/script-utils/standalone/start.go @@ -0,0 +1,52 @@ +// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Author: arnej + +// for starting standalone jdisc containers +package standalone + +import ( + "os" + + "github.com/vespa-engine/vespa/client/go/jvm" + "github.com/vespa-engine/vespa/client/go/trace" + "github.com/vespa-engine/vespa/client/go/util" + "github.com/vespa-engine/vespa/client/go/vespa" +) + +func commonPreChecks() { + if doTrace := os.Getenv("TRACE_JVM_STARTUP"); doTrace != "" { + trace.AdjustVerbosity(1) + } + if doDebug := os.Getenv("DEBUG_JVM_STARTUP"); doDebug != "" { + trace.AdjustVerbosity(2) + } + veHome := vespa.FindAndVerifyVespaHome() + err := os.Chdir(veHome) + if err != nil { + util.JustExitWith(err) + } + err = vespa.LoadDefaultEnv() + if err != nil { + util.JustExitWith(err) + } +} + +func StartStandaloneContainer(extraArgs []string) int { + commonPreChecks() + util.TuneResourceLimits() + serviceName := os.Getenv("VESPA_SERVICE_NAME") + if serviceName == "" { + util.JustExitMsg("Missing service name, ensure VESPA_SERVICE_NAME is set in the environment") + } + c := jvm.NewStandaloneContainer(serviceName) + jvmOpts := c.JvmOptions() + for _, extra := range extraArgs { + jvmOpts.AddOption(extra) + } + minFallback := jvm.MegaBytesOfMemory(128) + maxFallback := jvm.MegaBytesOfMemory(2048) + jvmOpts.AddDefaultHeapSizeArgs(minFallback, maxFallback) + c.Exec() + // unreachable: + return 1 +} |