mover los archivos fallados a otro directorio

de lo contrario detienen el envío porque el stack siempre devuelve el fallado
This commit is contained in:
f 2022-03-03 15:07:45 -03:00
parent 4411d7ee0c
commit 2feee6f70b
3 changed files with 10 additions and 5 deletions

View file

@ -18,6 +18,7 @@ sudo mkdir -vp $install_dir/archives/logs
sudo mkdir $historical
sudo mkdir $stack
sudo mkdir $corrupt
sudo mkdir $failed
echo ""
sudo cp -vr $files $install_dir
sudo cp -v $config /etc/nodemecu.conf

View file

@ -15,3 +15,4 @@ stack=$install_dir/stack
historical=$install_dir/historical
log=$install_dir/errors.log
corrupt=$install_dir/corrupt
failed=$install_dir/failed

View file

@ -24,15 +24,18 @@ while :;do
if [ $test_url -ne 200 ];then
echo "$(date +%Y-%m-%d-%H:%M:%S) - $url - $test_url" >> $log && sleep 300 && continue
fi
file="$stack/$file"
local_transaction_uuid="$(echo "$file" | cut -d - -f 2-)"
remote_transaction=$(curl -s --connect-timeout 1 --show-error -w "~%{http_code}" -X POST -H "Content-Type: application/json" -d @$file $url 2> $curl_err)
remote_response="$(echo $remote_transaction | cut -d '~' -f 1)"
server_error="$(echo $remote_transaction | cut -d '~' -f 2)"
if [ ${#remote_response} -eq 36 ];then
if [ $local_transaction_uuid == $remote_response ]; then
mv $stack/$file $historical
echo -e "$remote_response: \e[92mOK\e[0m"
fi
if [ "$local_transaction_uuid" = "$remote_response" ]; then
mv $file $historical
echo -e "$remote_response: \e[92mOK\e[0m"
else
mv $file $failed
echo -e "$local_transaction_uuid: \e[91mFAIL\e[0m"
# errores
unset srv_msg