-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathrun-dev.sh
executable file
·56 lines (45 loc) · 1.38 KB
/
run-dev.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
#!/bin/bash
set -e
set -u
PROFILE=false
if [ "${1:-}" = "--help" ]; then
echo "Usage: $0 [--help|--profile|<command>]"
exit 0
elif [ "${1:-}" = "--profile" ]; then
PROFILE=true
fi
if [ "${1:-}" = "clean" ]; then
docker image rm --no-prune meshping:latest-dev
exit 0
fi
if [ -z "$(docker image ls -q meshping:latest-dev)" ]; then
docker build --network host -t meshping:latest-dev .
fi
mkdir -p /tmp/statistico
function parse_result () {
if [ -e "/tmp/statistico/profile.bin" ]; then
echo "Parsing results..."
python3 \
-c 'import pstats; pstats.Stats("/tmp/statistico/profile.bin").sort_stats("cumulative").print_stats()' \
> /tmp/statistico/profile.txt
cat /tmp/statistico/profile.txt
echo "Results are available in /tmp/statistico/profile.txt."
fi
}
trap parse_result exit
if [ "$PROFILE" = "true" ]; then
echo "Running meshping with profiling enabled. Hit ^c to stop."
COMMAND="python3 -m cProfile -o /tmp/statistico/profile.bin src/meshping.py"
else
echo "Running meshping. Hit ^c to stop."
COMMAND="$@"
fi
docker run --rm -it --net=host \
-e MESHPING_DEV=true \
-e TZ=${TZ:-Europe/Berlin} \
-v /tmp/statistico:/tmp/statistico \
-v $PWD/db:/opt/meshping/db \
-v $PWD/src:/opt/meshping/src \
-v $PWD/ui/src:/opt/meshping/ui/src \
meshping:latest-dev \
$COMMAND