ocket8888 commented on a change in pull request #6532:
URL: https://github.com/apache/trafficcontrol/pull/6532#discussion_r796841346



##########
File path: dev/atc.dev.sh
##########
@@ -0,0 +1,160 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+alias atc-start="docker-compose up -d --build";
+alias atc-build="docker-compose build";
+alias atc-stop="docker-compose down -v --remove-orphans";
+alias atc-restart="atc-stop && atc-start";
+
+function atc-ready {
+       local url="https://localhost:6443/api/4.0/ping";;
+       if [[ $# -gt 0 ]]; then
+               case "$1" in
+                       -w|--wait)
+                               while ! curl -skL "$url" >/dev/null 2>&1; do
+                                       sleep 1;
+                               done
+                               return 0;;
+                       -h|--help)
+                               echo "Usage: $0 [-h] [-w]";
+                               echo "";
+                               echo "-h, --help  print usage information and 
exit";
+                               echo "-w, --wait  wait for ATC to be ready, 
instead of just checking if it is ready";
+                               return 0;;
+                       *)
+                               echo "Usage: $0 [-h] [-w]" >&2;
+                               echo "" >&2;
+                               echo "-h, --help  print usage information and 
exit" >&2;
+                               echo "-w, --wait  wait for ATC to be ready, 
instead of just checking if it is ready" >&2;
+                               return 1;;
+               esac
+       fi
+       curl -skL "$url" >/dev/null 2>&1;
+       return $?;
+}
+
+function atc-exec {
+       if [[ $# -lt 2 ]]; then
+               echo "Usage: atc-exec SERVICE CMD" >&2;
+               return 1;
+       fi;
+       local service="trafficcontrol_$1_1";
+       shift;
+       docker exec "$service" $@;
+       return $?;
+}
+
+function atc-connect {
+       if [[ $# -ne 1 ]]; then
+               echo "Usage: atc-connect SERVICE" >&2;
+               return 1;
+       fi;
+       docker exec -it "trafficcontrol_$1_1" /bin/sh;
+       return $?;
+}
+
+function atc {
+       if [[ $# -lt 1 ]]; then
+               echo "Usage: atc OPERATION" >&2;
+               return 1;
+       fi
+       local arg="$1";
+       shift;
+       case "$arg" in
+               build)
+                       atc-build $@;;
+               connect)
+                       atc-connect $@;;
+               exec)
+                       atc-exec $@;;
+               ready)
+                       atc-ready $@;;
+               restart)
+                       atc-restart $@;;
+               start)
+                       atc-start $@;;
+               stop)
+                       atc-stop $@;;
+               -h|--help|/\?)
+                       echo "Usage: atc OPERATION";
+                       echo "";
+                       echo "Valid OPERATIONs:";
+                       echo "  build   Build the images for the environment, 
but do not start it";
+                       echo "  connect Connect to a shell session inside a dev 
container";
+                       echo "  exec    Run a command in a dev container";
+                       echo "  ready   Check if the development environment is 
ready";
+                       echo "  restart Retart up the development environment";
+                       echo "  start   Start up the development environment";
+                       echo "  stop    Stop the development environment";
+                       ;;
+               *)
+                       echo "Usage: atc OPERATION" >&2;
+                       echo "" >&2;
+                       echo "Valid OPERATIONs:" >&2;
+                       echo "  build   Build the images for the environment, 
but do not start it" >&2;
+                       echo "  connect Connect to a shell session inside a dev 
container" >&2;
+                       echo "  exec    Run a command in a dev container" >&2;
+                       echo "  ready   Check if the development environment is 
ready" >&2;
+                       echo "  restart Retart up the development environment" 
>&2;
+                       echo "  start   Start up the development environment" 
>&2;
+                       echo "  stop    Stop the development environment" >&2;
+                       return 2;;
+       esac
+       return "$?";
+}
+
+export t3cDir="/root/go/src/github.com/apache/trafficcontrol/cache-config";
+
+function t3c {
+       trap 'atc-exec t3c ps | grep dlv | tr -s " " | cut -d " " -f1 | xargs 
docker exec trafficcontrol_t3c_1 kill' INT;
+       local dExec=(docker exec);
+       local dlv=();
+       if [[ ! -z "$TC_WAIT" ]]; then
+               dlv=(dlv --accept-multiclient --listen=:8081 --headless 
--api-version=2 debug --);
+       else;

Review comment:
       I didn't see that because apparently ZSH is fine with it




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to