<commit_before>#!/bin/bash

set -e

########################################################################################
PORT_TO_SWITCH_FROM=$bamboo_tomcat_PORT_TO_UNDEPLOY
PORT_TO_SWITCH_TO=$bamboo_tomcat_PORT_TO_DEPLOY
########################################################################################

# echo variables of this job
echo "PORT_TO_SWITCH_FROM=$PORT_TO_SWITCH_FROM"
echo "PORT_TO_SWITCH_TO=$PORT_TO_SWITCH_TO"
# echo variables of previous (deploy) job
echo "PORT_TO_DEPLOY=$bamboo_tomcat_PORT_TO_DEPLOY"
echo "PORT_TO_UNDEPLOY=$bamboo_tomcat_PORT_TO_UNDEPLOY"
stdout_file="osm_${bamboo_tomcat_HOST_TO_REVERSE_PROXY}_${PORT_TO_SWITCH_TO}_blue-green-switch-stdout.txt"

# run blue/green switch on target machine

ssh -p $bamboo_tomcat_SSH_PORT_TO_REVERSE_PROXY -o "StrictHostKeyChecking no" $bamboo_tomcat_JENKINS_USER_NAME@$bamboo_tomcat_HOST_TO_REVERSE_PROXY \
	"sudo /opt/osm_blue_green_switch.sh $PORT_TO_SWITCH_FROM $PORT_TO_SWITCH_TO $bamboo_tomcat_OSM_REVERSE_PROXY_URL $bamboo_tomcat_OSM_REVERSE_PROXY_IP OpenSpeedMonitor > /tmp/${stdout_file}" \
    || scp -P $bamboo_tomcat_SSH_PORT_TO_REVERSE_PROXY -o "StrictHostKeyChecking no" $bamboo_tomcat_JENKINS_USER_NAME@$bamboo_tomcat_HOST_TO_REVERSE_PROXY:"/tmp/$stdout_file" .

echo "stdout of blue-green-switch remote execution:"
cat ./$stdout_file
echo "END of stdout of blue-green-switch remote execution"

# undeploy old version
if [ $PORT_TO_SWITCH_FROM -ne -1 ];
	then
		curl -u $bamboo_tomcat_TOMCAT_ADMIN_USERNAME:$bamboo_tomcat_TOMCAT_ADMIN_PASSWORD http://$bamboo_tomcat_HOST_TO_DEPLOY_TO:$PORT_TO_SWITCH_FROM/manager/text/undeploy\?path\=/OpenSpeedMonitor
fi<commit_msg>WIP improve logging in blue green switch ci script<commit_after>#!/bin/bash

set -e

########################################################################################
PORT_TO_SWITCH_FROM=$bamboo_tomcat_PORT_TO_UNDEPLOY
PORT_TO_SWITCH_TO=$bamboo_tomcat_PORT_TO_DEPLOY
########################################################################################

# echo variables of this job
echo "PORT_TO_SWITCH_FROM=$PORT_TO_SWITCH_FROM"
echo "PORT_TO_SWITCH_TO=$PORT_TO_SWITCH_TO"
# echo variables of previous (deploy) job
echo "PORT_TO_DEPLOY=$bamboo_tomcat_PORT_TO_DEPLOY"
echo "PORT_TO_UNDEPLOY=$bamboo_tomcat_PORT_TO_UNDEPLOY"
stdout_file="osm_${bamboo_tomcat_HOST_TO_REVERSE_PROXY}_${PORT_TO_SWITCH_TO}_blue-green-switch-stdout.txt"

# run blue/green switch on target machine

ssh -p $bamboo_tomcat_SSH_PORT_TO_REVERSE_PROXY -o "StrictHostKeyChecking no" $bamboo_tomcat_JENKINS_USER_NAME@$bamboo_tomcat_HOST_TO_REVERSE_PROXY \
	"sudo /opt/osm_blue_green_switch.sh $PORT_TO_SWITCH_FROM $PORT_TO_SWITCH_TO $bamboo_tomcat_OSM_REVERSE_PROXY_URL $bamboo_tomcat_OSM_REVERSE_PROXY_IP OpenSpeedMonitor &> /tmp/${stdout_file}" \
    || scp -P $bamboo_tomcat_SSH_PORT_TO_REVERSE_PROXY -o "StrictHostKeyChecking no" $bamboo_tomcat_JENKINS_USER_NAME@$bamboo_tomcat_HOST_TO_REVERSE_PROXY:"/tmp/$stdout_file" .

echo "stdout of blue-green-switch remote execution:"
cat ./$stdout_file
echo "END of stdout of blue-green-switch remote execution"

# undeploy old version
if [ $PORT_TO_SWITCH_FROM -ne -1 ];
	then
		curl -u $bamboo_tomcat_TOMCAT_ADMIN_USERNAME:$bamboo_tomcat_TOMCAT_ADMIN_PASSWORD http://$bamboo_tomcat_HOST_TO_DEPLOY_TO:$PORT_TO_SWITCH_FROM/manager/text/undeploy\?path\=/OpenSpeedMonitor
fi
{'fraction_non_alphanumeric': 0.18016676593210243, 'fraction_numerical': 0.0005955926146515784, 'mean_word_length': 10.01311475409836, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '2257161', 'n_tokens_mistral': 1355, 'n_tokens_neox': 1272, 'n_words': 171}