-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstack
executable file
·105 lines (87 loc) · 2.63 KB
/
stack
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
#!/usr/bin/env bash
set -euo pipefail
IFS=$'\n\t'
export DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
export RUN_LILYPAD=${RUN_LILYPAD:-""}
export LILYPAD_DIR=${LILYPAD_DIR:-"$DIR/../lilypad"}
export TMUX_SESSION=${TMUX_SESSION:="lilysaas"}
function check-for-lilypad() {
if [ ! -d "$LILYPAD_DIR" ]; then
echo "Lilypad directory not found at $LILYPAD_DIR"
exit 1
fi
}
function lilypad-stack() {
check-for-lilypad
(
set -euo pipefail
cd $LILYPAD_DIR
./stack "$@"
)
}
function generate-golang-bindings() {
check-for-lilypad
(
set -euo pipefail
cd $LILYPAD_DIR
./stack generate-golang-bindings contract "$DIR/api/pkg/contract"
)
echo "Generated Go bindings"
}
function psql() {
docker-compose exec postgres psql --user postgres "$@"
}
function start() {
if tmux has-session -t "$TMUX_SESSION" 2>/dev/null; then
echo "Session $TMUX_SESSION already exists. Attaching..."
sleep 1
tmux -2 attach -t $TMUX_SESSION
exit 0;
fi
export MANUALRUN=1
export LOG_LEVEL=debug
if [[ -n "$RUN_LILYPAD" ]]; then
echo "Starting lilypad"
lilypad-stack boot
fi
echo "Starting docker-compose"
docker-compose up -d
sleep 2
echo "Creating tmux session $TMUX_SESSION..."
# get the size of the window and create a session at that size
local screensize=$(stty size)
local width=$(echo -n "$screensize" | awk '{print $2}')
local height=$(echo -n "$screensize" | awk '{print $1}')
tmux -2 new-session -d -s $TMUX_SESSION -x "$width" -y "$(($height - 1))"
tmux split-window -v -d
tmux select-pane -t 1
tmux split-window -v -d
tmux select-pane -t 0
tmux split-window -v -d
tmux send-keys -t 0 'docker-compose logs -f frontend' C-m
tmux send-keys -t 1 'docker-compose exec api bash' C-m
tmux send-keys -t 1 'go run . serve' C-m
tmux send-keys -t 2 './stack psql'
if [[ -n "$RUN_LILYPAD" ]]; then
tmux select-pane -t 3
tmux split-window -h -d
tmux select-pane -t 4
tmux split-window -v -d
tmux select-pane -t 4
tmux split-window -v -d
tmux select-pane -t 6
tmux split-window -v -d
tmux send-keys -t 3 './stack lilypad-stack bacalhau-serve' C-m
tmux send-keys -t 4 './stack lilypad-stack solver --server-url http://172.17.0.1:8080' C-m
tmux send-keys -t 5 'sleep 10 && ./stack lilypad-stack mediator' C-m
tmux send-keys -t 6 'sleep 10 && ./stack lilypad-stack resource-provider' C-m
fi
tmux -2 attach-session -t $TMUX_SESSION
}
function stop() {
echo "Stopping tmux session $TMUX_SESSION..."
tmux kill-session -t $TMUX_SESSION
echo "Removing docker containers"
docker rm -f $(docker ps -aq) || true
}
eval "$@"