summaryrefslogtreecommitdiffstats
path: root/configserver/src/main/sh/start-configserver
blob: a18b19535bb23b1b8fa635824d5214df8c3cee5a (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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
#!/bin/sh
# Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

# BEGIN environment bootstrap section
# Do not edit between here and END as this section should stay identical in all scripts

findpath () {
    myname=${0}
    mypath=${myname%/*}
    myname=${myname##*/}
    if [ "$mypath" ] && [ -d "$mypath" ]; then
        return
    fi
    mypath=$(pwd)
    if [ -f "${mypath}/${myname}" ]; then
        return
    fi
    echo "FATAL: Could not figure out the path where $myname lives from $0"
    exit 1
}

COMMON_ENV=libexec/vespa/common-env.sh

source_common_env () {
    if [ "$VESPA_HOME" ] && [ -d "$VESPA_HOME" ]; then
        # ensure it ends with "/" :
        VESPA_HOME=${VESPA_HOME%/}/
        export VESPA_HOME
        common_env=$VESPA_HOME/$COMMON_ENV
        if [ -f "$common_env" ]; then
            . $common_env
            return
        fi
    fi
    return 1
}

findroot () {
    source_common_env && return
    if [ "$VESPA_HOME" ]; then
        echo "FATAL: bad VESPA_HOME value '$VESPA_HOME'"
        exit 1
    fi
    if [ "$ROOT" ] && [ -d "$ROOT" ]; then
        VESPA_HOME="$ROOT"
        source_common_env && return
    fi
    findpath
    while [ "$mypath" ]; do
        VESPA_HOME=${mypath}
        source_common_env && return
        mypath=${mypath%/*}
    done
    echo "FATAL: missing VESPA_HOME environment variable"
    echo "Could not locate $COMMON_ENV anywhere"
    exit 1
}

findroot

# END environment bootstrap section

cd ${VESPA_HOME} || { echo "Cannot cd to ${VESPA_HOME}" 1>&2; exit 1; }

if [ -f ${VESPA_HOME}conf/zookeeper/zookeeper.cfg ]; then
    chown ${VESPA_USER} ${VESPA_HOME}conf/zookeeper/zookeeper.cfg
    chmod 644 ${VESPA_HOME}conf/zookeeper/zookeeper.cfg
fi

if [ -f ${VESPA_HOME}var/zookeeper/myid ]; then
    chown ${VESPA_USER} ${VESPA_HOME}var/zookeeper/myid
    chmod 644 ${VESPA_HOME}var/zookeeper/myid
fi

${VESPA_HOME}libexec/vespa/vespa-config.pl -isthisaconfigserver 1>/dev/null
if [ "$?" != "0" ] ; then
    echo "Not able to start config server, host `hostname` is not part of 'services.addr_configserver'"
    exit 1;
fi

fixlimits
checkjava

ZOOKEEPER_DATA_PATH="${VESPA_HOME}var/zookeeper/version-2"
if [ ! -d "$ZOOKEEPER_DATA_PATH" ]; then
    echo "Creating data directory $ZOOKEEPER_DATA_PATH"
    mkdir -p $ZOOKEEPER_DATA_PATH
    chown yahoo:users $ZOOKEEPER_DATA_PATH
fi

ZOOKEEPER_LOG_FILE="${VESPA_HOME}logs/vespa/zookeeper.configserver.log"
rm -f $ZOOKEEPER_LOG_FILE*lck

# common setup
export VESPA_LOG_TARGET=file:${VESPA_HOME}logs/vespa/vespa.log
export VESPA_LOG_CONTROL_DIR="${VESPA_HOME}var/db/vespa/logcontrol"
export VESPA_LOG_CONTROL_FILE="${VESPA_HOME}var/db/vespa/logcontrol/configserver.logcontrol"
export VESPA_SERVICE_NAME=configserver
export LD_LIBRARY_PATH=${VESPA_HOME}lib64

#Does not need fast allocation
export MALLOC_ARENA_MAX=1

vespa-run-as-vespa-user ${VESPA_HOME}libexec/vespa/start-filedistribution
vespa-run-as-vespa-user ${VESPA_HOME}libexec/vespa/start-logd

# stuff for the configserver process:

appdir="${VESPA_HOME}conf/configserver-app"
pidfile="${VESPA_HOME}var/run/configserver.pid"
cfpfile="${VESPA_HOME}var/jdisc_core/configserver.properties"
bundlecachedir="${VESPA_HOME}var/vespa/bundlecache/configserver"

export JAVAVM_LD_PRELOAD=
unset LD_PRELOAD
# will be picked up by standalone-container:
export standalone_jdisc_container__app_location=${appdir}
export standalone_jdisc_container__deployment_profile=configserver

# class path
CP="${VESPA_HOME}lib/jars/jdisc_core-jar-with-dependencies.jar"

baseuserargs="$vespa_base__jvmargs_configserver"
serveruserargs="$cloudconfig_server__jvmargs"
jvmargs="$baseuserargs $serveruserargs"

printenv > $cfpfile
mkdir -p $bundlecachedir
chown -R ${VESPA_USER} $bundlecachedir

vespa-run-as-vespa-user vespa-runserver -s configserver -r 30 -p $pidfile -- \
	java \
	-Xms128m -Xmx2048m \
	-XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=${VESPA_HOME}var/crash \
	-XX:OnOutOfMemoryError='kill -9 %p' \
	$jvmargs \
	-Djava.library.path=${VESPA_HOME}lib64 \
	-Djava.awt.headless=true \
	-Dsun.rmi.dgc.client.gcInterval=3600000 \
	-Dsun.net.client.defaultConnectTimeout=5000 -Dsun.net.client.defaultReadTimeout=60000 \
	-Djavax.net.ssl.keyStoreType=JKS \
	-Djdisc.config.file=$cfpfile \
	-Djdisc.export.packages= \
	-Djdisc.cache.path=$bundlecachedir \
	-Djdisc.debug.resources=false \
	-Djdisc.bundle.path=${VESPA_HOME}lib/jars \
	-Djdisc.logger.enabled=true \
	-Djdisc.logger.level=ALL \
	-Djdisc.logger.tag=jdisc/configserver \
	-Dfile.encoding=UTF-8 \
	-Dzookeeperlogfile=${VESPA_HOME}logs/vespa/zookeeper.configserver.log \
	-cp "$CP" \
	com.yahoo.jdisc.core.StandaloneMain standalone-container-jar-with-dependencies.jar