forked from helixml/helix
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstack
More file actions
executable file
·117 lines (96 loc) · 3.07 KB
/
stack
File metadata and controls
executable file
·117 lines (96 loc) · 3.07 KB
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
106
107
108
109
110
111
112
113
114
115
116
117
#!/usr/bin/env bash
set -euo pipefail
IFS=$'\n\t'
export DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
export TMUX_SESSION=${TMUX_SESSION:="helix"}
export WITH_RUNNER=${WITH_RUNNER:=""}
function mock-runner() {
go run . runner \
--mock-runner \
--api-host http://localhost \
--api-token oh-hallo-insecure-token \
--memory 24GB \
--runner-id mock \
--label gpu=4090 "$@"
}
function build() {
docker-compose -f docker-compose.dev.yaml build
}
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
echo "Starting docker-compose"
if [[ -n "$WITH_RUNNER" ]]; then
docker-compose -f docker-compose.dev.yaml --profile dev_gpu_runner up --build -d
else
docker-compose -f docker-compose.dev.yaml up -d
fi
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 select-pane -t 0
tmux split-window -v -d
tmux send-keys -t 0 'docker-compose -f docker-compose.dev.yaml 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 'docker-compose exec unstructured bash' C-m
tmux send-keys -t 2 'python3 src/main.py' C-m
if [[ -n "$WITH_RUNNER" ]]; then
tmux send-keys -t 3 'docker-compose --profile dev_gpu_runner -f docker-compose.dev.yaml exec dev_gpu_runner bash' C-m
tmux send-keys -t 3 'go run . runner --api-host http://172.17.0.1 --api-token oh-hallo-insecure-token --memory 24GB --runner-id dev-runner' C-m
fi
tmux -2 attach-session -t $TMUX_SESSION
}
function stop() {
echo "Removing docker containers"
docker-compose --profile dev_gpu_runner -f docker-compose.dev.yaml down
echo "Stopping tmux session $TMUX_SESSION..."
tmux kill-session -t $TMUX_SESSION ||true
}
function up() {
docker-compose -f docker-compose.dev.yaml up -d
}
function rebuild() {
docker-compose -f docker-compose.dev.yaml up -d --build api
}
function db() {
local subcommand="${1-cli}"
shift
if [[ "$subcommand" == "cli" ]]; then
docker-compose exec postgres psql --user postgres "$@"
elif [[ "$subcommand" == "pipe" ]]; then
docker-compose exec -T postgres psql --user postgres "$@"
fi
}
# Regenerate test mocks
function generate() {
go generate ./...
}
function psql() {
db cli "$@"
}
function psql_pipe() {
db pipe "$@"
}
function update_openapi() {
go install github.com/swaggo/swag/cmd/swag@latest && \
swag init -g api/pkg/server/swagger.go \
--parseDependency --parseInternal --parseDepth 3 \
-o api/pkg/server
}
eval "$@"