You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
2.4 KiB
2.4 KiB
Deploy no Servidor da Empresa (Debian/Ubuntu + systemd)
1) Fluxo correto com Git
Sim: primeiro voce faz commit e push da sua maquina local, depois no servidor faz pull.
Exemplo:
# local
git add .
git commit -m "ajusta mysql/tools + telegram webhook"
git push origin main
# servidor
cd /opt/orquestrador
git pull origin main
2) Preparacao no servidor
cd /opt/orquestrador
python3 -m venv venv
source venv/bin/activate
pip install -U pip
pip install -r requirements.txt
3) Configurar .env.prod
Crie/atualize o arquivo .env.prod no servidor:
GOOGLE_PROJECT_ID=seu-projeto
GOOGLE_LOCATION=us-central1
VERTEX_MODEL_NAME=gemini-2.5-flash
DB_HOST=127.0.0.1
DB_PORT=3306
DB_USER=root
DB_PASSWORD=sua_senha
DB_NAME=orquestrador_mock
MOCK_DB_HOST=127.0.0.1
MOCK_DB_PORT=3306
MOCK_DB_USER=root
MOCK_DB_PASSWORD=sua_senha
MOCK_DB_NAME=orquestrador_mock
AUTO_SEED_TOOLS=true
AUTO_SEED_MOCK=true
MOCK_SEED_ENABLED=true
# telegram (opcional)
# TELEGRAM_BOT_TOKEN=...
# TELEGRAM_WEBHOOK_SECRET=...
4) Credencial para Vertex AI
Defina um dos formatos abaixo no servidor:
GOOGLE_APPLICATION_CREDENTIALS=/opt/orquestrador/sa.json- ou Application Default Credentials (
gcloud auth application-default login)
A service account deve ter permissao no Vertex AI (ex.: roles/aiplatform.user).
5) Configurar service do systemd
- Copie o template e ajuste usuario/path:
sudo cp deploy/systemd/orquestrador.service.example /etc/systemd/system/orquestrador.service
sudo nano /etc/systemd/system/orquestrador.service
- Recarregue e inicie:
sudo systemctl daemon-reload
sudo systemctl enable --now orquestrador
sudo systemctl status orquestrador
- Logs:
journalctl -u orquestrador -f
6) Testes rapidos
curl -s http://127.0.0.1:8080/openapi.json | head
curl -s -X POST http://127.0.0.1:8080/chat \
-H "Content-Type: application/json" \
-d '{"message":"Quero um sedan ate 50000"}'
curl -s -X POST http://127.0.0.1:8080/mock/consultar-estoque \
-H "Content-Type: application/json" \
-d '{"preco_max":50000,"categoria":"sedan"}'
7) Atualizacao em producao
Sempre que subir novas mudancas:
cd /opt/orquestrador
git pull origin main
source venv/bin/activate
pip install -r requirements.txt
sudo systemctl restart orquestrador
sudo systemctl status orquestrador