-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart_visualizer.sh
More file actions
executable file
·40 lines (31 loc) · 1.15 KB
/
start_visualizer.sh
File metadata and controls
executable file
·40 lines (31 loc) · 1.15 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
#!/bin/bash
# Script to start the visualizer API in a tmux session
SESSION_NAME="api"
# If tmux is not installed, run without tmux
if ! command -v tmux &>/dev/null; then
echo "tmux is not installed. Running without tmux."
# Run 'gw' if available, then start the visualizer API
if command -v gw &>/dev/null; then
gw
fi
python ~/gridworks-visualizer/visualizer/visualizer_api.py
exit 0
fi
# Check if tmux session already exists
if tmux has-session -t "$SESSION_NAME" 2>/dev/null; then
echo "Session '$SESSION_NAME' already exists. Attaching..."
tmux attach-session -t "$SESSION_NAME"
else
echo "Creating new tmux session '$SESSION_NAME'..."
# Create a new tmux session and run commands
tmux new-session -d -s "$SESSION_NAME" -c "$(pwd)"
sleep 0.5
# Run 'gw' command (your alias)
tmux send-keys -t "$SESSION_NAME" "gw" C-m
# Wait a moment for gw to complete
sleep 0.5
# Start the visualizer API
tmux send-keys -t "$SESSION_NAME" "python ~/gridworks-visualizer/visualizer/visualizer_api.py" C-m
# Attach to the session
tmux attach-session -t "$SESSION_NAME"
fi