<commit_before>#!/bin/bash

#
# Run all neccessary Docker container to run a zipkin tracing/logging app:
# Usage: ./stop.sh      		--> runs zipkin containers and connects ports 
# 	 ./stop.sh  -c|--cleanup  	--> stops and removes old containers; 
# 	 ./stop.sh  -s|--stop 	--> stop old containers; 
#
# The second run needs to remove old containers; 
# If not, docker will complain about the container
# container name beeing allready assigned.
# 


## this file contains configuration and functions
source ./utils.sh
 
# test for input parameter
case "$1" in

# ----------------------------------------------------------- #
 -c|--cleanup)
# ----------------------------------------------------------- #
  echo " Cleaning up  services  "
   LOGDATE="$(date '+%F-%M-%S')"
  for i in "${SERVICES[@]}"; do
    echo "** Commiting  zipkin-$i to ${IMG_PREFIX}$i:$LOGDATE"
    ##TODO chef if container exists and then commit
    sudo docker commit "${NAME_PREFIX}$i ${IMG_PREFIX}$i:$LOGDATE" #&>/dev/null	#redirect stdout&stderror 
    echo "** Stopping zipkin-$i"
    sudo docker stop "${NAME_PREFIX}$i" &>/dev/null	#redirect stdout&stderror 
    echo "** Removing zipkin-$i"
    sudo docker rm "${NAME_PREFIX}$i"   &>/dev/null     
  done
    sudo docker images | grep $LOGDATE
    exit 
	;;
# ----------------------------------------------------------- #
 -s|--stop)
# ----------------------------------------------------------- #
    echo " Stopping  services  "
    RUNNING=0
    for i in "${SERVICES[@]}"; do
      echo "** Stopping zipkin-$i"
      sudo docker stop "${NAME_PREFIX}$i" &>/dev/null	#redirect stdout&stderror 
      sudo docker ps -a | grep Exited  | grep $IMG_PREFIX &>/dev/null
      if [ $? -eq 0  ]
      then 
	  (( RUNNING += 1 ))
      fi<commit_msg> commiting container to local repe before deleting it<commit_after>#!/bin/bash

#
# Run all neccessary Docker container to run a zipkin tracing/logging app:
# Usage: ./stop.sh      		--> runs zipkin containers and connects ports 
# 	 ./stop.sh  -c|--cleanup  	--> stops and removes old containers; 
# 	 ./stop.sh  -s|--stop 	--> stop old containers; 
#
# The second run needs to remove old containers; 
# If not, docker will complain about the container
# container name beeing allready assigned.
# 


## this file contains configuration and functions
source ./utils.sh
 
# test for input parameter
case "$1" in

# ----------------------------------------------------------- #
 -c|--cleanup)
# ----------------------------------------------------------- #
  echo " Cleaning up  services  "
   LOGDATE="$(date '+%F-%M-%S')"
  for i in "${SERVICES[@]}"; do
    echo "** Commiting  zipkin-$i to ${IMG_PREFIX}$i:$LOGDATE"
    ##TODO check if container exists and then commit
    echo "sudo docker commit zipkin-$i ${IMG_PREFIX}$i:$LOGDATE" #&>/dev/null	#redirect stdout&stderror 
    sudo docker commit "${NAME_PREFIX}$i" "${IMG_PREFIX}$i:$LOGDATE" #&>/dev/null	#redirect stdout&stderror 
    echo "** Stopping zipkin-$i"
    sudo docker stop "${NAME_PREFIX}$i" &>/dev/null	#redirect stdout&stderror 
    echo "** Removing zipkin-$i"
    sudo docker rm "${NAME_PREFIX}$i"   &>/dev/null     
  done
  echo "** These images are in the local repository:" 
  sudo docker images | grep $LOGDATE
  exit 
	;;
# ----------------------------------------------------------- #
 -s|--stop)
# ----------------------------------------------------------- #
    echo " Stopping  services  "
    RUNNING=0
    for i in "${SERVICES[@]}"; do
      echo "** Stopping zipkin-$i"
      sudo docker stop "${NAME_PREFIX}$i" &>/dev/null	#redirect stdout&stderror 
      sudo docker ps -a | grep Exited  | grep $IMG_PREFIX &>/dev/null
      if [ $? -eq 0  ]
      then 
	  (( RUNNING += 1 ))
      fi
{'fraction_non_alphanumeric': 0.2518043303929431, 'fraction_numerical': 0.0021384656508954825, 'mean_word_length': 1.8521341463414633, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 20, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4773671', 'n_tokens_mistral': 1163, 'n_tokens_neox': 1090, 'n_words': 348}