Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions proc/Envia2SciELOFast.bat
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@ rem ===== Aumentar o espaco de variaveis de ambiente
rem CONFIG.SYS
rem

rem Envia2Medline
rem Envia2SciELOFast
rem Parametro 1: path da producao da SciELO
rem Parametro 2: arquivo com instrucoes de FTP
rem Parametro 3: arquivo de log
rem Parametro 4: cria / adiciona
rem Parametro 5: (Opcional) path alternativo da base de artigos

rem Inicializa variaveis
export INFORMALOG=log/Envia2Medline.log
export INFORMALOG=log/Envia2SciELOFast.log
export CISIS_DIR=cisis

rem Verifica parametros
Expand All @@ -34,7 +35,12 @@ call batch/CriaDiretorio.bat temp/transf2scielofast
call batch/GeraIso.bat $1/title/title temp/transf2scielofast/title_full.iso

call batch/CriaMaster.bat temp/transf2scielofast/artigo_full_temp
call batch/AppendMaster.bat $1/artigo/artigo temp/transf2scielofast/artigo_full_temp prc/apaga_autores_772.prc
ARTIGOSOURCE=$1/artigo/artigo
if [ "$5" != "" ]
then
ARTIGOSOURCE=$5
fi
call batch/AppendMaster.bat ${ARTIGOSOURCE} temp/transf2scielofast/artigo_full_temp prc/apaga_autores_772.prc

call batch/GeraIso.bat temp/transf2scielofast/artigo_full_temp temp/transf2scielofast/artigo_full.iso

Expand Down
42 changes: 41 additions & 1 deletion proc/GeraScielo.bat
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,41 @@ call batch/GeraInvertido.bat ../bases-work/newissue/newissue fst/newissue.fst ..

call batch/CriaRevistasNovas.bat $1
call batch/GeraIssues.bat $1

# ==============================================================================
# PROPOSITO: GeraArtigoFast.bat

GERAPADRAO_STATUS=""
ARQUIVO_STATUS="temp/GeraArtigoFastGeraPadraoStatus.ctrl"

# 1. Le o status removendo potenciais quebras de linha do Windows (\r)
if [ -f "${ARQUIVO_STATUS}" ]
then
GERAPADRAO_STATUS=$(tr -d '\r' < "${ARQUIVO_STATUS}" 2>/dev/null)
fi

# 2. Desvio condicional para o modo FAST
if [ "${GERAPADRAO_STATUS}" == "RUNNING" ]
then
call batch/GeraArtigoFastLockCheck.bat ${ARQUIVO_STATUS} 72 tecnologia@scielo.org

call batch/InformaLog.bat $0 dh === Executando Fluxo FAST (Status: RUNNING) ===

# Executa o batch especial para o fluxo rápido
call batch/GeraArtigoFast.bat $1

# Registra o fim antecipado no log e encerra com sucesso (exit 0)
call batch/InformaLog.bat $0 dh === Fim Antecipado (Fluxo FAST) === LOG gravado em: $INFORMALOG

# Finaliza execucao com sucesso, mas sem finalizar de forma padrão
exit 0
fi

# ==============================================================================
# PROPOSITO: GeraArtigoFast.bat
echo "RUNNING" > "${ARQUIVO_STATUS}"
# ==============================================================================

call batch/GeraArtigo.bat $1

call batch/GeraFacCount.bat $1
Expand All @@ -78,4 +113,9 @@ call batch/ManutencaoOn.bat ../bases
call batch/CopiaWork2Teste.bat ../bases-work ../bases
call batch/ManutencaoOff.bat ../bases

call batch/InformaLog.bat $0 dh ===Fim=== LOG gravado em: $INFORMALOG
# ==============================================================================
# PROPOSITO: GeraArtigoFast.bat
echo "FINISHED" > "${ARQUIVO_STATUS}"
# ==============================================================================

call batch/InformaLog.bat $0 dh ===Fim=== LOG gravado em: $INFORMALOG
16 changes: 16 additions & 0 deletions proc/batch/GeraArtigoFast.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
rem GeraArtigoFast
rem Parametro 1: path producao Scielo

call batch/VerifPresencaParametro.bat $0 @$1 path producao SciELO

call batch/CriaDiretorio.bat ../bases-work/fast
call batch/CriaMaster.bat ../bases-work/fast/artigo

$CISIS_DIR/mx $1/serial/title/title lw=9000 "pft=if v50='C' then 'call batch/AppendMaster.bat ../bases-work/',v68,'/',v68,x1,'../bases-work/fast/artigo',x1,'prc/d1930.prc'/ fi" now >temp/GeraArtigoFast.bat
batch/ifErrorLevel.bat $? batch/AchouErro.bat $0 mx $1/serial/title/title lw:9000 pft:call_GeraArtigo.bat
chmod 700 temp/GeraArtigoFast.bat
call temp/GeraArtigoFast.bat

echo "GeraArtigoFast: Envia de bases title e artigo do bases-work para FTP para carga em ArticleMeta"
call Envia2SciELOFast.bat ../bases-work transf/Envia2SciELOFastLogOn.txt log/enviaGeraArtigoFast.log cria ../bases-work/fast/artigo
echo "GeraArtigoFast: Fim de envio de bases"
23 changes: 23 additions & 0 deletions proc/batch/GeraArtigoFastLockCheck.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash
ARQUIVO="${1:-temp/GeraArtigoFastGeraPadraoStatus.ctrl}"
LIMIAR="${2:-72}"
EMAIL="${3:-tecnologia@scielo.org}"

[ -f "$ARQUIVO" ] || exit 0
[ "$(tr -d '\r' < "$ARQUIVO")" == "RUNNING" ] || exit 0

MTIME=$(stat -c %Y "$ARQUIVO" 2>/dev/null || stat -f %m "$ARQUIVO")
IDADE=$(( ($(date +%s) - MTIME) / 3600 ))
[ "$IDADE" -ge "$LIMIAR" ] || exit 0

DESDE=$(date -d "@$MTIME" +%d/%m/%Y\ %H:%M:%S 2>/dev/null || date -r "$MTIME" +%d/%m/%Y\ %H:%M:%S)

cat >temp/GeraArtigoFastGeraPadraoStatusMessage.txt <<!
A equipe de Infraestrutura,
Processamento GeraPadrao esta executando ha ${IDADE}h (limite: ${LIMIAR}h), status RUNNING desde ${DESDE}.
Favor verificar.
Processamento SciELO
!
mailx -s "[ALERTA-GeraArtigoFast] GeraPadrao RUNNING ${IDADE}h desde ${DESDE}" "$EMAIL" < temp/GeraArtigoFastGeraPadraoStatusMessage.txt
rm temp/GeraArtigoFastGeraPadraoStatusMessage.txt