<commit_before>#!/bin/bash -x

. /home/easydeploy/bin/env.sh

function kill_tree() {
    gpid=$(pgrep -o $1)
    if [[ ! -z $gpid ]]
    then
        kill -9 $(pstree -p ${gpid} | sed 's/(/\n(/g' | grep '(' | sed 's/(\(.*\)).*/\1/' | tr "\n" " ")
    fi
}

if ! service supervisor status
then
    echo "Supervisor not running, cannot restart component"
    exit 1
fi

touch /tmp/.restart-in-progress
/ezbin/lb_off.sh
sleep 60
supervisorctl stop ${COMPONENT}:
docker stop $(docker ps -q)
service docker.io stop
sleep 10
kill_tree run-docker.sh

sleep 30
cat /var/easydeploy/share/.config/discovery/all.txt
sleep 30
service docker.io start
supervisorctl start ${COMPONENT}:

count=0
while supervisorctl status |  grep -v "EXITED" | grep -v "RUNNING"
do
    echo "Waiting for supervisor processes to restart"
    count=$(( $count + 1 ))
    if (( $count > 30 ))
    then
        echo "Failed to restart component"
        /ezbin/notify.sh ":fire:" "Rebooting, could not restart component ${COMPONENT} due to supervisorctl statuses: $(supervisorctl status)"
        reboot
        exit 0
    else
        sleep 10
    fi
done
sleep 30
/ezbin/lb_on.sh


rm /tmp/.restart-in-progress
exit 0
<commit_msg>Preparing for blue/green<commit_after>#!/bin/bash -x

. /home/easydeploy/bin/env.sh

function kill_tree() {
    gpid=$(pgrep -o $1)
    if [[ ! -z $gpid ]]
    then
        kill -9 $(pstree -p ${gpid} | sed 's/(/\n(/g' | grep '(' | sed 's/(\(.*\)).*/\1/' | tr "\n" " ")
    fi
}

if ! service supervisor status
then
    echo "Supervisor not running, cannot restart component"
    exit 1
fi

touch /tmp/.restart-in-progress
/ezbin/lb_off.sh
sleep 60
supervisorctl stop ${COMPONENT}:
docker stop $(docker ps -a -q)
service docker.io stop
sleep 10
kill_tree run-docker.sh

sleep 30
cat /var/easydeploy/share/.config/discovery/all.txt
sleep 30
service docker.io start
supervisorctl start ${COMPONENT}:

count=0
while supervisorctl status |  grep -v "EXITED" | grep -v "RUNNING"
do
    echo "Waiting for supervisor processes to restart"
    count=$(( $count + 1 ))
    if (( $count > 30 ))
    then
        echo "Failed to restart component"
        /ezbin/notify.sh ":fire:" "Rebooting, could not restart component ${COMPONENT} due to supervisorctl statuses: $(supervisorctl status)"
        reboot
        exit 0
    else
        sleep 10
    fi
done
sleep 30
/ezbin/lb_on.sh


rm /tmp/.restart-in-progress
exit 0

{'fraction_non_alphanumeric': 0.1362126245847176, 'fraction_numerical': 0.018272425249169437, 'mean_word_length': 2.7640625, 'pattern_counts': {'":': 2, '<': 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': '940224', 'n_tokens_mistral': 903, 'n_tokens_neox': 829, 'n_words': 267}