forked from elastic/rally
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rallyd
executable file
·52 lines (45 loc) · 1.72 KB
/
rallyd
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
#!/usr/bin/env bash
# fail this script immediately if any command fails with a non-zero exit code
set -e
# see http://stackoverflow.com/a/246128
SOURCE="${BASH_SOURCE[0]}"
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
SOURCE="$(readlink "$SOURCE")"
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
done
RALLY_SRC_HOME="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
pushd . >/dev/null 2>&1
cd "${RALLY_SRC_HOME}" >/dev/null 2>&1
export PYTHONPATH=$RALLY_SRC_HOME:$PYTHONPATH
# see http://unix.stackexchange.com/a/155077
if output=$(git status --porcelain) && [ -z "$output" ] && on_master=$(git rev-parse --abbrev-ref HEAD) && [ "$on_master" == "master" ]
then
# Working directory clean -> we assume this is a user that is not actively developing Rally and just upgrade it every time it is invoked
set +e
# this will fail if the user is offline
git fetch origin --quiet >/dev/null 2>&1
exit_code=$?
set -e
if [ ${exit_code} == 0 ]
then
echo "Auto-updating Rally"
git rebase origin/master --quiet
python3 setup.py -q develop --user
#else
# offline - skipping update
fi
# else
# Uncommitted changes - don't upgrade, just run
fi
popd >/dev/null 2>&1
# Provide a consistent binary name to the user and hide the fact that we call another binary under the hood.
export RALLY_ALTERNATIVE_BINARY_NAME=$(basename "$0")
RALLY_ROOT=$(python3 -c "import site; print(site.USER_BASE)")
RALLY_BIN=${RALLY_ROOT}/bin/esrallyd
if [ -x "$RALLY_BIN" ]
then
${RALLY_BIN} "$@"
else
echo "Cannot execute Rally daemon in ${RALLY_BIN}."
fi