aboutsummaryrefslogtreecommitdiffstats
path: root/client/go/internal/admin/jvm/zk_locks.go
blob: 39b8dd0c64b36ac6be5b435c9ae563dc3b6530ed (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
// Copyright Yahoo. 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/trace"
	"github.com/vespa-engine/vespa/client/go/internal/util"
)

const (
	ZOOKEEPER_LOG_FILE_PREFIX = "logs/vespa/zookeeper"
)

func RemoveStaleZkLocks(c Container) {
	backticks := util.BackTicksWithStderr
	cmd := fmt.Sprintf("rm -f '%s/%s.%s'*lck", defaults.VespaHome(), ZOOKEEPER_LOG_FILE_PREFIX, c.ServiceName())
	trace.Trace("cleaning locks:", cmd)
	out, err := backticks.Run("/bin/sh", "-c", cmd)
	if err != nil {
		trace.Warning("Failure [", out, "] when running command:", cmd)
		util.JustExitWith(err)
	}
}