remove tmux
This commit is contained in:
parent
9802abd650
commit
00f11ab007
@ -60,12 +60,6 @@ variable "experiment_use_screen" {
|
|||||||
default = false
|
default = false
|
||||||
}
|
}
|
||||||
|
|
||||||
variable "experiment_use_tmux" {
|
|
||||||
type = bool
|
|
||||||
description = "Whether to use tmux instead of screen for running Claude Code in the background."
|
|
||||||
default = false
|
|
||||||
}
|
|
||||||
|
|
||||||
variable "experiment_report_tasks" {
|
variable "experiment_report_tasks" {
|
||||||
type = bool
|
type = bool
|
||||||
description = "Whether to enable task reporting."
|
description = "Whether to enable task reporting."
|
||||||
@ -84,17 +78,6 @@ variable "experiment_post_install_script" {
|
|||||||
default = null
|
default = null
|
||||||
}
|
}
|
||||||
|
|
||||||
variable "experiment_tmux_session_persistence" {
|
|
||||||
type = bool
|
|
||||||
description = "Whether to enable tmux session persistence across workspace restarts."
|
|
||||||
default = false
|
|
||||||
}
|
|
||||||
|
|
||||||
variable "experiment_tmux_session_save_interval" {
|
|
||||||
type = string
|
|
||||||
description = "How often to save tmux sessions in minutes."
|
|
||||||
default = "15"
|
|
||||||
}
|
|
||||||
|
|
||||||
variable "install_agentapi" {
|
variable "install_agentapi" {
|
||||||
type = bool
|
type = bool
|
||||||
@ -180,24 +163,6 @@ resource "coder_script" "claude_code" {
|
|||||||
command -v "$1" >/dev/null 2>&1
|
command -v "$1" >/dev/null 2>&1
|
||||||
}
|
}
|
||||||
|
|
||||||
install_tmux() {
|
|
||||||
echo "Installing tmux..."
|
|
||||||
if command_exists apt-get; then
|
|
||||||
sudo apt-get update && sudo apt-get install -y tmux
|
|
||||||
elif command_exists yum; then
|
|
||||||
sudo yum install -y tmux
|
|
||||||
elif command_exists dnf; then
|
|
||||||
sudo dnf install -y tmux
|
|
||||||
elif command_exists pacman; then
|
|
||||||
sudo pacman -S --noconfirm tmux
|
|
||||||
elif command_exists apk; then
|
|
||||||
sudo apk add tmux
|
|
||||||
else
|
|
||||||
echo "Error: Unable to install tmux automatically. Package manager not recognized."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
if [ ! -d "${local.workdir}" ]; then
|
if [ ! -d "${local.workdir}" ]; then
|
||||||
echo "Warning: The specified folder '${local.workdir}' does not exist."
|
echo "Warning: The specified folder '${local.workdir}' does not exist."
|
||||||
echo "Creating the folder..."
|
echo "Creating the folder..."
|
||||||
@ -283,89 +248,11 @@ resource "coder_script" "claude_code" {
|
|||||||
/tmp/post_install.sh
|
/tmp/post_install.sh
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "${var.experiment_use_tmux}" = "true" ] && [ "${var.experiment_use_screen}" = "true" ]; then
|
if ! command_exists claude; then
|
||||||
echo "Error: Both experiment_use_tmux and experiment_use_screen cannot be true simultaneously."
|
echo "Error: Claude Code is not installed. Please enable install_claude_code or install it manually."
|
||||||
echo "Please set only one of them to true."
|
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "${var.experiment_tmux_session_persistence}" = "true" ] && [ "${var.experiment_use_tmux}" != "true" ]; then
|
|
||||||
echo "Error: Session persistence requires tmux to be enabled."
|
|
||||||
echo "Please set experiment_use_tmux = true when using session persistence."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "${var.experiment_use_tmux}" = "true" ]; then
|
|
||||||
if ! command_exists tmux; then
|
|
||||||
install_tmux
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "${var.experiment_tmux_session_persistence}" = "true" ]; then
|
|
||||||
echo "Setting up tmux session persistence..."
|
|
||||||
if ! command_exists git; then
|
|
||||||
echo "Git not found, installing git..."
|
|
||||||
if command_exists apt-get; then
|
|
||||||
sudo apt-get update && sudo apt-get install -y git
|
|
||||||
elif command_exists yum; then
|
|
||||||
sudo yum install -y git
|
|
||||||
elif command_exists dnf; then
|
|
||||||
sudo dnf install -y git
|
|
||||||
elif command_exists pacman; then
|
|
||||||
sudo pacman -S --noconfirm git
|
|
||||||
elif command_exists apk; then
|
|
||||||
sudo apk add git
|
|
||||||
else
|
|
||||||
echo "Error: Unable to install git automatically. Package manager not recognized."
|
|
||||||
echo "Please install git manually to enable session persistence."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
mkdir -p ~/.tmux/plugins
|
|
||||||
if [ ! -d ~/.tmux/plugins/tpm ]; then
|
|
||||||
git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm
|
|
||||||
fi
|
|
||||||
|
|
||||||
cat > ~/.tmux.conf << EOF
|
|
||||||
# Claude Code tmux persistence configuration
|
|
||||||
set -g @plugin 'tmux-plugins/tmux-resurrect'
|
|
||||||
set -g @plugin 'tmux-plugins/tmux-continuum'
|
|
||||||
|
|
||||||
# Configure session persistence
|
|
||||||
set -g @resurrect-processes ':all:'
|
|
||||||
set -g @resurrect-capture-pane-contents 'on'
|
|
||||||
set -g @resurrect-save-bash-history 'on'
|
|
||||||
set -g @continuum-restore 'on'
|
|
||||||
set -g @continuum-save-interval '${var.experiment_tmux_session_save_interval}'
|
|
||||||
set -g @continuum-boot 'on'
|
|
||||||
set -g @continuum-save-on 'on'
|
|
||||||
|
|
||||||
# Initialize plugin manager
|
|
||||||
run '~/.tmux/plugins/tpm/tpm'
|
|
||||||
EOF
|
|
||||||
|
|
||||||
~/.tmux/plugins/tpm/scripts/install_plugins.sh
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "Running Claude Code in the background with tmux..."
|
|
||||||
touch "$HOME/.claude-code.log"
|
|
||||||
export LANG=en_US.UTF-8
|
|
||||||
export LC_ALL=en_US.UTF-8
|
|
||||||
|
|
||||||
tmux new-session -d -s agentapi-cc -c ${local.workdir} '~/.agentapi-start-command true; exec bash'
|
|
||||||
~/.agentapi-wait-for-start-command
|
|
||||||
|
|
||||||
if [ "${var.experiment_tmux_session_persistence}" = "true" ]; then
|
|
||||||
sleep 3
|
|
||||||
fi
|
|
||||||
|
|
||||||
if ! tmux has-session -t claude-code 2>/dev/null; then
|
|
||||||
# Only create a new session if one doesn't exist
|
|
||||||
tmux new-session -d -s claude-code -c ${local.workdir} "agentapi attach; exec bash"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "${var.experiment_use_screen}" = "true" ]; then
|
|
||||||
echo "Running Claude Code in the background..."
|
echo "Running Claude Code in the background..."
|
||||||
if ! command_exists screen; then
|
if ! command_exists screen; then
|
||||||
echo "Error: screen is not installed. Please install screen manually."
|
echo "Error: screen is not installed. Please install screen manually."
|
||||||
@ -398,18 +285,6 @@ EOF
|
|||||||
exec bash
|
exec bash
|
||||||
'
|
'
|
||||||
~/.agentapi-wait-for-start-command
|
~/.agentapi-wait-for-start-command
|
||||||
|
|
||||||
screen -U -dmS claude-code bash -c '
|
|
||||||
cd ${local.workdir}
|
|
||||||
agentapi attach
|
|
||||||
exec bash
|
|
||||||
'
|
|
||||||
else
|
|
||||||
if ! command_exists claude; then
|
|
||||||
echo "Error: Claude Code is not installed. Please enable install_claude_code or install it manually."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
EOT
|
EOT
|
||||||
run_on_start = true
|
run_on_start = true
|
||||||
}
|
}
|
||||||
@ -440,21 +315,6 @@ resource "coder_app" "claude_code" {
|
|||||||
export LANG=en_US.UTF-8
|
export LANG=en_US.UTF-8
|
||||||
export LC_ALL=en_US.UTF-8
|
export LC_ALL=en_US.UTF-8
|
||||||
|
|
||||||
if [ "${var.experiment_use_tmux}" = "true" ]; then
|
|
||||||
if ! tmux has-session -t agentapi-cc 2>/dev/null; then
|
|
||||||
# start agentapi without claude using the prompt (no argument)
|
|
||||||
tmux new-session -d -s agentapi-cc -c ${local.workdir} '~/.agentapi-start-command; exec bash'
|
|
||||||
~/.agentapi-wait-for-start-command
|
|
||||||
fi
|
|
||||||
|
|
||||||
if tmux has-session -t claude-code 2>/dev/null; then
|
|
||||||
echo "Attaching to existing Claude Code tmux session." | tee -a "$HOME/.claude-code.log"
|
|
||||||
tmux attach-session -t claude-code
|
|
||||||
else
|
|
||||||
echo "Starting a new Claude Code tmux session." | tee -a "$HOME/.claude-code.log"
|
|
||||||
tmux new-session -s claude-code -c ${local.workdir} "agentapi attach; exec bash"
|
|
||||||
fi
|
|
||||||
elif [ "${var.experiment_use_screen}" = "true" ]; then
|
|
||||||
if ! screen -list | grep -q "agentapi-cc"; then
|
if ! screen -list | grep -q "agentapi-cc"; then
|
||||||
screen -S agentapi-cc bash -c '
|
screen -S agentapi-cc bash -c '
|
||||||
cd ${local.workdir}
|
cd ${local.workdir}
|
||||||
@ -463,17 +323,8 @@ resource "coder_app" "claude_code" {
|
|||||||
exec bash
|
exec bash
|
||||||
'
|
'
|
||||||
fi
|
fi
|
||||||
if screen -list | grep -q "claude-code"; then
|
|
||||||
echo "Attaching to existing Claude Code screen session." | tee -a "$HOME/.claude-code.log"
|
|
||||||
screen -xRR claude-code
|
|
||||||
else
|
|
||||||
echo "Starting a new Claude Code screen session." | tee -a "$HOME/.claude-code.log"
|
|
||||||
screen -S claude-code bash -c 'agentapi attach; exec bash'
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
cd ${local.workdir}
|
|
||||||
agentapi attach
|
agentapi attach
|
||||||
fi
|
|
||||||
EOT
|
EOT
|
||||||
icon = var.icon
|
icon = var.icon
|
||||||
order = var.order
|
order = var.order
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user