<commit_before>#!/bin/sh
set -e

fail() { echo "Error: ${1}" 1>&2; exit 1; }

TYPE=${1}
SOURCE="/etc/monit/templates/alert-${TYPE}"
DEST="/etc/monit/conf.d/alert"

if ! (test -e "${SOURCE}"); then
  fail "Source template not found: ${SOURCE}"
fi

rm -f ${DEST}
ln -s ${SOURCE} ${DEST}
monit reload<commit_msg>Wait for "monit reload" to succeed before ending "monit-alert"<commit_after>#!/bin/sh
set -e

fail() { echo "Error: ${1}" 1>&2; exit 1; }

TYPE=${1}
SOURCE="/etc/monit/templates/alert-${TYPE}"
DEST="/etc/monit/conf.d/alert"

if ! (test -e "${SOURCE}"); then
  fail "Source template not found: ${SOURCE}"
fi

rm -f ${DEST}
ln -s ${SOURCE} ${DEST}

function checkMonitHasReloaded {
  monit summary | grep -q 'uptime: 0m'
}
RELOAD_CHECK_BEFORE=$(checkMonitHasReloaded)$?

monit reload

if [[ 0 != ${RELOAD_CHECK_BEFORE} ]]; then
  while ! (checkMonitHasReloaded); do sleep 0.05; done
else
  sleep 1
fi
{'fraction_non_alphanumeric': 0.19625137816979052, 'fraction_numerical': 0.017640573318632856, 'mean_word_length': 4.437125748502994, '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': '5384244', 'n_tokens_mistral': 374, 'n_tokens_neox': 358, 'n_words': 98}