forked from grafana/pyroscope
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstart.sh
executable file
·69 lines (54 loc) · 1.41 KB
/
start.sh
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
#!/bin/bash
set -e
echo "building containers..."
source ./run-parameters.env
export PYROSCOPE_CPUS PYROSCOPE_MEMORY
export DOCKER_BUILDKIT=1
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
LOCKFILE=$SCRIPT_DIR/lock
trap 'rc=$?; echo "ERR at line ${LINENO} (rc: $rc)"; cleanup; exit $rc' ERR
trap 'rc=$?; echo "EXIT (rc: $rc)"; cleanup; exit $rc' EXIT
wait=false
function cleanup() {
lockContent=`cat $LOCKFILE`
if [[ "$lockContent" -eq "$$" ]]; then
echo "Removing lock file..."
rm "$LOCKFILE"
fi
# TODO(eh-am): what to do when this fails?
docker-compose down --remove-orphans
}
function run() {
docker-compose build > /dev/null
docker-compose up -d \
--remove-orphans
# TODO(eh-am): docker-compose exec
docker exec benchmark_pyrobench_1 ./pyrobench loadgen \
--server-address="http://pyroscope:4040" \
--pushgateway-address="http://pushgateway:9091"
if [ "$wait" = true ]; then
echo "Finished, waiting since --wait flag is true"
sleep 24h
fi
}
if [ -f "$LOCKFILE" ]; then
echo "Already running... will now terminate."
exit
else
echo "Acquiring lock..."
echo $$ > "$LOCKFILE"
fi
while [[ $# -gt 0 ]]; do
key="$1"
case $key in
-w|--wait)
wait=true
shift # past argument
;;
*) # unknown option
shift # past argument
;;
esac
done
set -- "${POSITIONAL[@]}" # restore positional parameters
run