-
Notifications
You must be signed in to change notification settings - Fork 2
/
rc
executable file
·73 lines (67 loc) · 2.73 KB
/
rc
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
#!/bin/bash
# Spin up or attach to tumx running Check development services.
usage() {
echo "usage: ${0##*/}" 1>&2
echo "" 1>&2
echo "Spin or attach to tumx running Check development services." 1>&2
echo "" 1>&2
echo "options:" 1>&2
echo " -h or --help shows usage help" 1>&2
exit 1
}
if echo "$*" | grep -Eq -- '--help\b|-h\b'; then
usage
fi
SRC="$(basename "$PWD")"
django_runserver_cmd() {
echo "pipenv run python manage.py runserver $1 2>&1 | jq -R -r '. as \$line | try fromjson catch \$line'"
}
if tmux ls | grep -q "$SRC"; then
tmux attach-session -t "$SRC"
else
if [[ $SRC == "check-api" ]]; then
tmux new -d -s "$SRC" -x "$(tput cols)" -y "$(tput lines)"
tmux send-keys "docker compose up" Enter
until psql -h "0.0.0.0" -U "postgres" -p 54320 -c '\q' 2>/dev/null; do
echo >&2 "postgres is unavailable - sleeping"
sleep 1
done
tmux split-window -hp 90
tmux send-keys "exitconda && entervirtualenv && source env/bin/activate" Enter
tmux send-keys "$(django_runserver_cmd localhost:8000)" Enter
tmux attach-session -t "$SRC"
elif [[ $SRC == "console" ]]; then
tmux new -d -s "$SRC" -x "$(tput cols)" -y "$(tput lines)"
tmux send-keys 'redis-server "$(brew --prefix)/etc/redis.conf"' Enter
until pgrep -f redis 2>/dev/null; do
echo >&2 "redis is unavailable - sleeping"
sleep 1
done
tmux split-window -hp 90
tmux send-keys "exitconda && entervirtualenv && source env/bin/activate" Enter
tmux send-keys "$(django_runserver_cmd localhost:8004)" Enter
tmux split-window -v
tmux send-keys "yarn run start" Enter
tmux attach-session -t "$SRC"
elif [[ $SRC == "kyb-ui" ]]; then
tmux new -d -s "$SRC" -x "$(tput cols)" -y "$(tput lines)"
tmux send-keys 'redis-server "$(brew --prefix)/etc/redis.conf"' Enter
until pgrep -f redis 2>/dev/null; do
echo >&2 "redis is unavailable - sleeping"
sleep 1
done
tmux split-window -hp 90
tmux send-keys "exitconda && entervirtualenv && source env/bin/activate" Enter
tmux send-keys "$(django_runserver_cmd localhost:8005)" Enter
tmux split-window -v
tmux send-keys "yarn run start" Enter
tmux attach-session -t "$SRC"
elif [[ $SRC == "onboard" ]]; then
tmux new -d -s "$SRC" -x "$(tput cols)" -y "$(tput lines)"
tmux send-keys "exitconda && entervirtualenv && source env/bin/activate" Enter
tmux send-keys "$(django_runserver_cmd localhost:8080)" Enter
tmux split-window -v
tmux send-keys "yarn run start" Enter
tmux attach-session -t "$SRC"
fi
fi