support daemon mode for ACTION == exec

This commit is contained in:
Drew Botwinick
2026-02-23 23:12:52 -06:00
parent 3c27d521bb
commit a276a76be2

View File

@@ -404,8 +404,8 @@ if [[ "$ACTION" == "status" ]]; then
fi fi
# Trap signals # Trap signals
# Only trap if we are NOT in daemon mode, OR if we are in exec mode (always cleanup after exec) # Only trap if we are NOT in daemon mode (container should persist in daemon mode)
if [[ "$DAEMON_MODE" == "false" ]] || [[ "$ACTION" == "exec" ]]; then if [[ "$DAEMON_MODE" == "false" ]]; then
trap cleanup EXIT INT TERM HUP trap cleanup EXIT INT TERM HUP
fi fi
@@ -698,6 +698,11 @@ if [[ "$ACTION" == "exec" ]]; then
start_cluster start_cluster
echo "Executing command on head node: $COMMAND_TO_RUN" echo "Executing command on head node: $COMMAND_TO_RUN"
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
# Check if running in a TTY to avoid "input device is not a TTY" error # Check if running in a TTY to avoid "input device is not a TTY" error
if [ -t 0 ]; then if [ -t 0 ]; then
DOCKER_EXEC_FLAGS="-it" DOCKER_EXEC_FLAGS="-it"
@@ -706,6 +711,7 @@ if [[ "$ACTION" == "exec" ]]; then
fi fi
docker exec $DOCKER_EXEC_FLAGS "$CONTAINER_NAME" bash -i -c "$COMMAND_TO_RUN" docker exec $DOCKER_EXEC_FLAGS "$CONTAINER_NAME" bash -i -c "$COMMAND_TO_RUN"
fi
elif [[ "$ACTION" == "start" ]]; then elif [[ "$ACTION" == "start" ]]; then
start_cluster start_cluster
if [[ "$DAEMON_MODE" == "true" ]]; then if [[ "$DAEMON_MODE" == "true" ]]; then