blob: 859aea9157d1f6f4c25386dde6b8fed72e65d5a6 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
// Author: arnej
package jvm
import (
"fmt"
"github.com/vespa-engine/vespa/client/go/internal/admin/defaults"
"github.com/vespa-engine/vespa/client/go/internal/admin/envvars"
"github.com/vespa-engine/vespa/client/go/internal/admin/prog"
"github.com/vespa-engine/vespa/client/go/internal/util"
)
const (
JAR_FOR_STANDALONE_CONTAINER = "standalone-container-jar-with-dependencies.jar"
)
type StandaloneContainer struct {
containerBase
}
func (a *StandaloneContainer) ArgForMain() string {
return JAR_FOR_STANDALONE_CONTAINER
}
func (a *StandaloneContainer) ServiceName() string {
return a.serviceName
}
func (a *StandaloneContainer) ConfigId() string {
return ""
}
func (a *StandaloneContainer) configureOptions() {
opts := a.jvmOpts
opts.ConfigureCpuCount(0)
opts.AddCommonXX()
opts.AddOption("-XX:-OmitStackTraceInFastThrow")
opts.AddCommonOpens()
opts.AddCommonJdkProperties()
a.addJdiscProperties()
svcName := a.ServiceName()
if svcName == "configserver" {
RemoveStaleZkLocks(a)
logsDir := defaults.UnderVespaHome("logs/vespa")
zkLogFile := fmt.Sprintf("%s/zookeeper.%s", logsDir, svcName)
opts.AddOption("-Dzookeeper_log_file_prefix=" + zkLogFile)
}
}
func NewStandaloneContainer(svcName string) Container {
var a StandaloneContainer
a.serviceName = svcName
a.jvmOpts = NewOptions(&a)
a.configureOptions()
return &a
}
func (a *StandaloneContainer) addJdiscProperties() {
opts := a.JvmOptions()
opts.AddCommonJdiscProperties()
containerParentDir := defaults.UnderVespaHome("var/jdisc_container")
bCacheParentDir := defaults.UnderVespaHome("var/vespa/bundlecache")
svcName := a.ServiceName()
bCacheDir := fmt.Sprintf("%s/%s", bCacheParentDir, svcName)
propsFile := fmt.Sprintf("%s/%s.properties", containerParentDir, svcName)
opts.fixSpec.FixDir(containerParentDir)
opts.fixSpec.FixDir(bCacheParentDir)
opts.fixSpec.FixDir(bCacheDir)
a.propsFile = propsFile
opts.AddOption("-Djdisc.export.packages=")
opts.AddOption("-Djdisc.config.file=" + propsFile)
opts.AddOption("-Djdisc.cache.path=" + bCacheDir)
opts.AddOption("-Djdisc.logger.tag=" + svcName)
}
func (c *StandaloneContainer) exportExtraEnv(ps *prog.Spec) {
vespaHome := defaults.VespaHome()
app := fmt.Sprintf("%s/conf/%s-app", vespaHome, c.ServiceName())
if util.IsDirectory(app) {
ps.Setenv(envvars.STANDALONE_JDISC_APP_LOCATION, app)
} else {
util.JustExitMsg("standalone container requires an application directory, missing: " + app)
}
}
|