From a276a76be23edd9b395a358d3d5a9e1ce6c729a6 Mon Sep 17 00:00:00 2001 From: Drew Botwinick Date: Mon, 23 Feb 2026 23:12:52 -0600 Subject: [PATCH 1/2] support daemon mode for ACTION == exec --- launch-cluster.sh | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/launch-cluster.sh b/launch-cluster.sh index c014d6b..2fe36dc 100755 --- a/launch-cluster.sh +++ b/launch-cluster.sh @@ -404,8 +404,8 @@ if [[ "$ACTION" == "status" ]]; then fi # Trap signals -# Only trap if we are NOT in daemon mode, OR if we are in exec mode (always cleanup after exec) -if [[ "$DAEMON_MODE" == "false" ]] || [[ "$ACTION" == "exec" ]]; then +# Only trap if we are NOT in daemon mode (container should persist in daemon mode) +if [[ "$DAEMON_MODE" == "false" ]]; then trap cleanup EXIT INT TERM HUP fi @@ -697,15 +697,21 @@ wait_for_cluster() { if [[ "$ACTION" == "exec" ]]; then start_cluster echo "Executing command on head node: $COMMAND_TO_RUN" - - # Check if running in a TTY to avoid "input device is not a TTY" error - if [ -t 0 ]; then - DOCKER_EXEC_FLAGS="-it" + + if [[ "$DAEMON_MODE" == "true" ]]; then + # Daemon mode: run command detached inside the container and exit immediately + docker exec -d "$CONTAINER_NAME" bash -c "$COMMAND_TO_RUN" + echo "Command dispatched in background (Daemon mode). Container: $CONTAINER_NAME" else - DOCKER_EXEC_FLAGS="-i" + # Check if running in a TTY to avoid "input device is not a TTY" error + if [ -t 0 ]; then + DOCKER_EXEC_FLAGS="-it" + else + DOCKER_EXEC_FLAGS="-i" + fi + + docker exec $DOCKER_EXEC_FLAGS "$CONTAINER_NAME" bash -i -c "$COMMAND_TO_RUN" fi - - docker exec $DOCKER_EXEC_FLAGS "$CONTAINER_NAME" bash -i -c "$COMMAND_TO_RUN" elif [[ "$ACTION" == "start" ]]; then start_cluster if [[ "$DAEMON_MODE" == "true" ]]; then From c1c3b9d66ab946b8c9ba33504b27bb578a18ab69 Mon Sep 17 00:00:00 2001 From: Eugene Rakhmatulin Date: Thu, 26 Feb 2026 15:23:08 -0800 Subject: [PATCH 2/2] support for daemon mode with exec command --- launch-cluster.sh | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/launch-cluster.sh b/launch-cluster.sh index c5276f4..0a23b2f 100755 --- a/launch-cluster.sh +++ b/launch-cluster.sh @@ -119,17 +119,8 @@ while [[ "$#" -gt 0 ]]; do break ;; *) - # If it's not a flag and not a known action, treat as exec command for backward compatibility - # unless it's the default 'start' implied. - # However, to support "omitted" = start, we need to be careful. - # If the arg looks like a command, it's exec. - if [[ -n "$LAUNCH_SCRIPT_PATH" ]]; then - echo "Error: Command is not compatible with --launch-script. Please omit the command or not use --launch-script." - exit 1 - fi - ACTION="exec" - COMMAND_TO_RUN="$@" - break + echo "Error: Unknown argument or action: $1" + usage ;; esac shift @@ -701,7 +692,8 @@ if [[ "$ACTION" == "exec" ]]; then if [[ "$DAEMON_MODE" == "true" ]]; then # Daemon mode: run command detached inside the container and exit immediately - docker exec -d "$CONTAINER_NAME" bash -c "$COMMAND_TO_RUN" + # Extract env vars starting from VLLM_HOST_IP to avoid interactive check in .bashrc + docker exec -d "$CONTAINER_NAME" bash -c "eval \"\$(sed -n '/export VLLM_HOST_IP/,\$p' /root/.bashrc)\" && $COMMAND_TO_RUN" echo "Command dispatched in background (Daemon mode). Container: $CONTAINER_NAME" else # Check if running in a TTY to avoid "input device is not a TTY" error