github.com/pingcap/tiflow@v0.0.0-20240520035814-5bf52d54e205/engine/test/utils/run_engine.sh (about)

     1  #!/bin/bash
     2  
     3  set -e
     4  
     5  cd "$(dirname "$0")/../../.."
     6  
     7  DOCKER_DIR="./deployments/engine/docker"
     8  
     9  if which docker-compose &>/dev/null; then
    10  	COMPOSECMD="docker-compose"
    11  else
    12  	COMPOSECMD="docker compose"
    13  fi
    14  
    15  function generate_flag() {
    16  	shift
    17  	while [[ ${1} ]]; do
    18  		flag=("${flag[@]}" -f "$1")
    19  		shift
    20  	done
    21  }
    22  
    23  case $1 in
    24  "build-local")
    25  	docker build -f $DOCKER_DIR/dev.Dockerfile -t dataflow:test .
    26  	;;
    27  "build")
    28  	docker build -f $DOCKER_DIR/Dockerfile -t dataflow:test .
    29  	;;
    30  "deploy")
    31  	flag=()
    32  	generate_flag "$@"
    33  	$COMPOSECMD "${flag[@]}" up -d --force-recreate
    34  
    35  	echo -e "\n\n[$(date)] <<<<<< deploy engine cluster success! >>>>>>"
    36  	docker container ls
    37  	;;
    38  "stop")
    39  	flag=()
    40  	generate_flag "$@"
    41  	$COMPOSECMD "${flag[@]}" kill || true
    42  	$COMPOSECMD "${flag[@]}" down || true
    43  
    44  	echo -e "\n\n[$(date)] <<<<<< stop engine cluster success! >>>>>>"
    45  	docker container ls
    46  	;;
    47  "logs")
    48  	shift && WORK_DIR=$1
    49  	flag=()
    50  	generate_flag "$@"
    51  	$COMPOSECMD "${flag[@]}" logs -t >$WORK_DIR/docker_compose.log || echo "fail to save logs"
    52  
    53  	echo -e "[$(date)] <<<<<< save docker compose logs success! >>>>>>\n"
    54  	;;
    55  *)
    56  	echo "Unknown parameter: ${1}" >&2
    57  	echo "Only support 'build-local','build','deploy','stop'" >&2
    58  	exit 1
    59  	;;
    60  esac