Skip to content

Commit cbaca0a

Browse files
committed
Add script to start a tmux monitoring session
1 parent 142c344 commit cbaca0a

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

bin/monitoring_session.sh

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/usr/bin/env bash
2+
3+
set -euo pipefail
4+
5+
SESSION_NAME="${1:-rails-docs-monitor}"
6+
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
7+
8+
if ! command -v tmux >/dev/null 2>&1; then
9+
echo "tmux is not installed or not found in PATH." >&2
10+
exit 1
11+
fi
12+
13+
if tmux has-session -t "$SESSION_NAME" 2>/dev/null; then
14+
exec tmux attach -t "$SESSION_NAME"
15+
fi
16+
17+
# Bootstrap the monitoring windows when the session does not already exist.
18+
tmux new-session -d -s "$SESSION_NAME" -n "btop" -c "$ROOT_DIR" "btop"
19+
tmux new-window -t "${SESSION_NAME}":2 -n "docs-log" -c "$HOME" "tail -F $HOME/docs_generation.log"
20+
tmux new-window -t "${SESSION_NAME}":3 -n "puma-hook" -c "$ROOT_DIR" "sudo journalctl -u rails-master-hook_puma_production -f"
21+
tmux new-window -t "${SESSION_NAME}":4 -n "hook-script" -c "$ROOT_DIR" "sudo journalctl -t rails-master-hook -f"
22+
tmux new-window -t "${SESSION_NAME}":5 -n "puma-error" -c "$HOME" "tail -F $HOME/rails-contributors/current/log/puma_error.log"
23+
tmux new-window -t "${SESSION_NAME}":6 -n "puma-access" -c "$HOME" "tail -F $HOME/current/log/puma_access.log"
24+
25+
tmux select-window -t "${SESSION_NAME}":1
26+
exec tmux attach -t "$SESSION_NAME"

0 commit comments

Comments
 (0)