-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_apps.sh
More file actions
executable file
·52 lines (41 loc) · 1.57 KB
/
run_apps.sh
File metadata and controls
executable file
·52 lines (41 loc) · 1.57 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
SESSION="food_delivery"
PROJECT_DIR=$(pwd)
# Leer argumentos o usar valores por defecto
RESTAURANTS=${1:-10}
RIDERS=${2:-15}
CLIENTS=${3:-20}
# Si la sesión existe, la matamos para empezar limpio
tmux has-session -t $SESSION 2>/dev/null
if [ $? -eq 0 ]; then
tmux kill-session -t $SESSION
fi
# Crear sesión nueva con ventana 'gateway' vacía y sin adjuntar
tmux new-session -d -s $SESSION -n gateway
##### GATEWAY #####
tmux send-keys -t $SESSION:gateway "cd $PROJECT_DIR && cargo run --bin gateway 0" C-m
sleep 0.5
##### RESTAURANTS #####
tmux new-window -t $SESSION -n restaurants
tmux send-keys -t $SESSION:restaurants "cd $PROJECT_DIR && cargo run --bin restaurant 0" C-m
for ((id=1; id<RESTAURANTS; id++)); do
tmux split-window -t $SESSION:restaurants -v "cd $PROJECT_DIR && cargo run --bin restaurant $id"
tmux select-layout -t $SESSION:restaurants tiled
done
sleep 2
##### RIDERS #####
tmux new-window -t $SESSION -n riders
tmux send-keys -t $SESSION:riders "cd $PROJECT_DIR && cargo run --bin rider 0" C-m
for ((id=1; id<RIDERS; id++)); do
tmux split-window -t $SESSION:riders -v "cd $PROJECT_DIR && cargo run --bin rider $id"
tmux select-layout -t $SESSION:riders tiled
done
sleep 2
##### CLIENTS #####
tmux new-window -t $SESSION -n clients
tmux send-keys -t $SESSION:clients "cd $PROJECT_DIR && cargo run --bin client 0" C-m
for ((id=1; id<CLIENTS; id++)); do
tmux split-window -t $SESSION:clients -v "cd $PROJECT_DIR && cargo run --bin client $id"
tmux select-layout -t $SESSION:clients tiled
done
# Finalmente adjuntamos la sesión
tmux attach-session -t $SESSION