summaryrefslogtreecommitdiffstats
path: root/client/go/jvm/container.go
blob: ac10f775859c4e1ec2187f958132451f0663d9e2 (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
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
// Author: arnej

package jvm

import (
	"github.com/vespa-engine/vespa/client/go/prog"
	"github.com/vespa-engine/vespa/client/go/util"
)

type Container interface {
	ServiceName() string
	ConfigId() string
	ArgForMain() string
	JvmOptions() *Options
	Exec()
}

type containerBase struct {
	configId    string
	serviceName string
	jvmArgs     *Options
}

func (cb *containerBase) ServiceName() string {
	return cb.serviceName
}

func (cb *containerBase) JvmOptions() *Options {
	return cb.jvmArgs
}

func (cb *containerBase) ConfigId() string {
	return cb.configId
}

func (cb *containerBase) Exec() {
	argv := make([]string, 0, 100)
	argv = append(argv, "java")
	for _, x := range cb.JvmOptions().Args() {
		argv = append(argv, x)
	}
	p := prog.NewSpec(argv)
	p.ConfigureNumaCtl()
	exportEnvSettings(cb, p)
	err := p.Run()
	util.JustExitWith(err)
}