aboutsummaryrefslogtreecommitdiffstats
path: root/client/go/internal/admin/vespa-wrapper/services/start.go
blob: 5e17ddb8c8d83575323b925506fe66e2dfdb0449 (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
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
// Author: arnej

package services

import (
	"fmt"
	"os"
	"strings"

	"github.com/vespa-engine/vespa/client/go/internal/admin/envvars"
	"github.com/vespa-engine/vespa/client/go/internal/admin/trace"
	"github.com/vespa-engine/vespa/client/go/internal/util"
	"github.com/vespa-engine/vespa/client/go/internal/vespa"
)

func StartServices() int {
	veHome, _ := commonPreChecks()
	vespa.CheckCorrectUser()
	trace.Debug("running as correct user")
	exportSettings(veHome)
	if vespa.HasOnlyIpV6() {
		os.Setenv(envvars.VESPA_ONLY_IP_V6_NETWORKING, "true")
	}
	startProxyWithRunserver()
	if waitForProxyResponse() {
		startSentinelWithRunserver()
		if waitForSentinelPid() {
			return 0
		}
	}
	return 1
}

func checkjava() {
	backticks := util.BackTicksWithStderr
	out, err := backticks.Run("java", "-version")
	if err != nil {
		trace.Warning("cannot run 'java -version'")
		util.JustExitWith(err)
	}
	if !strings.Contains(out, "64-Bit Server VM") {
		util.JustExitWith(fmt.Errorf("java must invoke the 64-bit Java VM, but -version says:\n%s\n", out))
	}
}

func runvalidation() {
	// not implemented
}

func VespaStartServices() int {
	home, host := commonPreChecks()
	trace.Debug("common prechecks ok, running in", home, "on", host)
	vespa.RunPreStart()
	trace.Debug("prestart ok")
	util.TuneResourceLimits()
	increase_vm_max_map_count()
	trace.Debug("resource limits ok")
	checkjava()
	trace.Debug("java ok")
	runvalidation()
	enable_transparent_hugepages_with_background_compaction()
	disable_vm_zone_reclaim_mode()
	drop_caches()
	err := vespa.MaybeSwitchUser("start-services")
	if err != nil {
		util.JustExitWith(err)
	}
	return StartServices()
}