name: comercialrs-local-deploy
description: Build and deploy ComercialRS (TanStack Start/Vite) on the VPS — this machine IS the webserver, so dist files go directly to /var/www/comercialrs/dist and nginx reloads to publish.
category: devops
ComercialRS — Build & Deploy (Local = VPS)
Context
The agent environment (this machine) shares the same public IP as the ComercialRS webserver:
- - Public IP:
31.97.243.106(eth0) - - Nginx serves
comercialrs.rochasalesseguros.com.brfrom/var/www/comercialrs/dist - - This means built files can be placed directly on disk — NO rsync/scp needed
- - Source:
/var/www/comercialrs/src/pages/Tasks.tsx(Reuniões filter) - - Source:
/var/www/comercialrs/src/pages/Sales.tsx(Vendas filter) - - Source:
/var/www/comercialrs/src/hooks/useMeetingAlerts.ts(alert timer) - - Build output:
/var/www/comercialrs/dist/ - - Nginx config:
/etc/nginx/sites-enabled/comercialrs.rochasalesseguros.com.br
Build Steps
`bash
export NVM_DIR="$HOME/.nvm" && source "$NVM_DIR/nvm.sh" && nvm use 20
cd /var/www/comercialrs
npm run build 2>&1 | tail -15
`
Deploy (nginx reload)
`bash
Files are already in /var/www/comercialrs/dist — just reload nginx
nginx -s reload
`
Verify Deployed Code
`bash
Check Tasks chunk for null-guard on dueDate
curl -sk "https://comercialrs.rochasalesseguros.com.br/assets/Tasks-CNEI19QL.js" | grep -o "!a.dueDate" | wc -l
Check Sales chunk for null-guard on createdAt
curl -sk "https://comercialrs.rochasalesseguros.com.br/assets/Sales-DNuPwFiH.js" | grep -o "!x.createdAt" | wc -l
Check alert timer (should be 150000 = 2h30min)
curl -sk "https://comercialrs.rochasalesseguros.com.br/assets/MeetingAlertsGlobal-Cx7J0J-1.js" | grep -o "setInterval(m,15e4)"
`
Key Files
Common Bug: Tasks/Sales filter crashes on null dueDate/createdAt
The date filters do .split('T') on dueDate or createdAt without checking for null.
Fix pattern:
`typescript
// ANTES — crasha em tasks com dueDate=null
if (dateFrom) {
const taskDate = t.dueDate.split('T')[0];
if (taskDate < dateFrom) return false;
}
// DEPOIS
if (dateFrom) {
if (!t.dueDate) return false;
const taskDate = t.dueDate.split('T')[0];
if (taskDate < dateFrom) return false;
}
`
Alert Timer Change
In useMeetingAlerts.ts, change interval from 30000 (30s) to 150000 (2h30min):
`typescript
const interval = setInterval(check, 150000); // 2h30min
`