Skip to content
Merged
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
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "eusei"
version = "0.5.4"
version = "0.5.5"
edition = "2021"
description = "API HTTP/JSON para os Web Services SOAP do SEI (espelha o pacote R rsei)"
license = "GPL-3.0-or-later"
Expand Down
85 changes: 85 additions & 0 deletions deploy/04-update-sudo.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
#!/usr/bin/env bash
# eusei — atualização SEGURA do binário em produção (e, opcionalmente, do snippet
# nginx). Para a instalação inicial use 02-deploy-sudo.sh; este script só atualiza.
#
# Rode como:
# sudo bash ~/eusei_dev/deploy/04-update-sudo.sh # só o binário
# sudo EUSEI_NGINX=1 bash ~/eusei_dev/deploy/04-update-sudo.sh # binário + nginx (p/ o SSE)
#
# O que faz (idempotente, seguro):
# 1. backup do binário atual em /opt/eusei/eusei.bak-<timestamp>;
# 2. instala o novo binário (compilado antes, sem sudo: cargo build --release);
# 3. (se EUSEI_NGINX=1) reinstala o snippet nginx e recarrega após `nginx -t`
# — necessário para o endpoint SSE /v1/andamentos/stream (proxy_buffering off);
# 4. systemctl restart + healthcheck no /health;
# 5. se o healthcheck falhar, ROLLBACK automático para o binário anterior.

set -euo pipefail

[[ $EUID -eq 0 ]] || { echo "Precisa de root. Rode: sudo bash $0" >&2; exit 1; }

DEV_USER="${SUDO_USER:?execute via sudo (precisa de SUDO_USER)}"
DEV_HOME="$(eval echo "~${DEV_USER}")"
DEV_DIR="${EUSEI_DEV_DIR:-${DEV_HOME}/eusei_dev}"
BIN_SRC="${DEV_DIR}/target/release/eusei"
BIN_DST="/opt/eusei/eusei"
SNIPPET_SRC="${DEV_DIR}/deploy/eusei.nginx.conf"
HEALTH="http://127.0.0.1:18088/health"
ts="$(date +%Y%m%d-%H%M%S 2>/dev/null || echo bak)"

[[ -f "$BIN_SRC" ]] || { echo "ERRO: binário não encontrado: $BIN_SRC" >&2
echo " compile antes (sem sudo): cd ~/eusei_dev && cargo build --release --locked" >&2; exit 1; }
[[ -f "$BIN_DST" ]] || { echo "ERRO: $BIN_DST não existe — para a 1ª instalação use 02-deploy-sudo.sh." >&2; exit 1; }

echo "== eusei update (dev user: ${DEV_USER}) =="
echo " versão em produção (antes): $(curl -s -m 3 "$HEALTH" 2>/dev/null | grep -oE '"version":"[^"]*"' || echo '?')"

# 1. backup do binário atual
BAK="${BIN_DST}.bak-${ts}"
cp -a "$BIN_DST" "$BAK"
echo " + backup do binário atual: $BAK"

# 2. instala o novo binário
install -m 0755 "$BIN_SRC" "$BIN_DST"
echo " + novo binário instalado em $BIN_DST"

# 3. (opcional) snippet nginx — para o SSE /v1/andamentos/stream
if [[ "${EUSEI_NGINX:-0}" == "1" ]]; then
install -d -m 0755 /etc/nginx/snippets
install -m 0644 "$SNIPPET_SRC" /etc/nginx/snippets/eusei.conf
if nginx -t; then
systemctl reload nginx
echo " + snippet nginx atualizado e nginx recarregado"
else
echo " ! nginx -t FALHOU — snippet instalado mas nginx NÃO recarregado. Revise manualmente." >&2
fi
fi

# 4. restart + healthcheck
systemctl restart eusei
ok=0
for _ in $(seq 1 10); do
sleep 1
if curl -fsS -m 3 "$HEALTH" >/dev/null 2>&1; then ok=1; break; fi
done

# 5. resultado / rollback
if [[ "$ok" == "1" ]]; then
echo " + serviço OK — versão agora: $(curl -s -m 3 "$HEALTH" | grep -oE '"version":"[^"]*"')"
echo
echo "== Pronto. Backup do binário anterior: $BAK =="
echo " Valide externamente: curl -s https://SEU-DOMINIO/eusei/health"
else
echo " ! healthcheck FALHOU após o restart — fazendo ROLLBACK para o binário anterior..." >&2
install -m 0755 "$BAK" "$BIN_DST"
systemctl restart eusei
sleep 2
if curl -fsS -m 3 "$HEALTH" >/dev/null 2>&1; then
echo " = rollback OK (versão anterior restaurada e no ar)." >&2
else
echo " !! rollback também falhou — serviço fora do ar. Veja: journalctl -u eusei -n 50 --no-pager" >&2
fi
echo "== FALHOU (provável config inválida no /etc/eusei.env p/ a nova validação). Logs:" >&2
echo " journalctl -u eusei -n 50 --no-pager" >&2
exit 1
fi
2 changes: 1 addition & 1 deletion static/docs.html
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
<!-- visão geral -->
<section id="visao-geral" class="scroll-mt-24">
<span class="inline-flex items-center gap-2 text-xs font-medium tracking-wide uppercase text-pine bg-pine/10 px-3 py-1.5 rounded-full">
<span class="w-1.5 h-1.5 rounded-full bg-pine"></span> read-only · v0.3
<span class="w-1.5 h-1.5 rounded-full bg-pine"></span> read-only · SEI Pernambuco
</span>
<h1 class="font-display text-4xl sm:text-5xl font-semibold tracking-tight mt-5">Documentação</h1>
<p class="text-lg text-muted leading-relaxed mt-4 max-w-2xl">
Expand Down
3 changes: 2 additions & 1 deletion static/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,11 @@ <h3 class="font-display text-xl font-semibold">Processos & documentos</h3>
<h3 class="font-display text-xl font-semibold">Andamentos</h3>
<ul class="mt-4 space-y-2 font-mono text-sm text-muted">
<li><span class="text-pine">GET</span> /v1/andamentos</li>
<li><span class="text-pine">GET</span> /v1/andamentos/stream <span class="text-muted/60">(SSE)</span></li>
<li><span class="text-pine">GET</span> /v1/documentos-processo</li>
<li><span class="text-pine">GET</span> /v1/publicacoes-processo</li>
</ul>
<p class="text-sm text-muted mt-4 leading-relaxed font-sans">Linha do tempo completa do processo, os documentos derivados dela e suas publicações.</p>
<p class="text-sm text-muted mt-4 leading-relaxed font-sans">Linha do tempo completa do processo (com progresso ao vivo via SSE), os documentos derivados dela e suas publicações. Respostas cacheadas, com <span class="font-mono text-xs">X-Cache</span>/<span class="font-mono text-xs">Cache-Control</span>.</p>
</div>
<div class="rounded-2xl border border-ink/8 bg-white/50 p-6 hover:border-pine/30 hover:shadow-lg hover:shadow-pine/5 transition">
<h3 class="font-display text-xl font-semibold">Listas</h3>
Expand Down
2 changes: 1 addition & 1 deletion static/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"openapi": "3.0.3",
"info": {
"title": "eusei — API dos Web Services do SEI",
"version": "0.5.4",
"version": "0.5.5",
"x-logo": {
"url": "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSI0NCIgaGVpZ2h0PSI0NCIgdmlld0JveD0iMCAwIDQ0IDQ0Ij48cmVjdCB3aWR0aD0iNDQiIGhlaWdodD0iNDQiIHJ4PSIxMSIgZmlsbD0iIzBFNkU1QyIvPjxnIGZpbGw9Im5vbmUiIHN0cm9rZT0iI0Y0RUZFMyIgc3Ryb2tlLXdpZHRoPSIyLjQiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCI+PHBhdGggZD0iTTEzIDE2SDMxIi8+PHBhdGggZD0iTTEzIDIySDI3Ii8+PHBhdGggZD0iTTEzIDI4SDIzIi8+PC9nPjxjaXJjbGUgY3g9IjMxLjUiIGN5PSIyOCIgcj0iMi42IiBmaWxsPSIjRThCMjNBIi8+PC9zdmc+",
"altText": "eusei",
Expand Down