diff --git a/README.md b/README.md index 6a970d8..f978b7d 100644 --- a/README.md +++ b/README.md @@ -412,10 +412,10 @@ Loguri aplicatie: `logs/sync_comenzi_*.log` ```bash # Conectare SSH (PowerShell remote, cheie publica) -ssh -p 22122 gomag@79.119.86.134 +ssh -i ~/.ssh/id_ed25519 -p 22122 -o StrictHostKeyChecking=no gomag@79.119.86.134 # Verificare .env -cmd /c type C:\gomag-vending\api\.env +powershell -Command "Get-Content C:\gomag-vending\api\.env | Select-String 'ORACLE_'" # Test conexiune Oracle C:\gomag-vending\venv\Scripts\python.exe -c "import oracledb, os; os.environ['TNS_ADMIN']='C:/roa/instantclient_11_2_0_2'; conn=oracledb.connect(user='VENDING', password='ROMFASTSOFT', dsn='ROA'); print('Connected!'); conn.close()" @@ -423,20 +423,80 @@ C:\gomag-vending\venv\Scripts\python.exe -c "import oracledb, os; os.environ['TN # Verificare tnsnames.ora cmd /c type C:\roa\instantclient_11_2_0_2\tnsnames.ora -# Verificare procese Python -Get-Process *python* | Select-Object Id,ProcessName,Path +# Verificare procese Python (ID-uri pentru kill/restart) +powershell -Command "Get-Process python -ErrorAction SilentlyContinue | Format-Table Id, CPU -AutoSize" # Verificare loguri recente Get-ChildItem C:\gomag-vending\logs\*.log | Sort-Object LastWriteTime -Descending | Select-Object -First 3 -# Test sync manual (verifica ca Oracle pool porneste) -curl http://localhost:5003/health -curl -X POST http://localhost:5003/api/sync/start +# Test app (prin nginx reverse proxy) +powershell -Command "Invoke-WebRequest -Uri 'http://localhost/gomag/' -UseBasicParsing | Select-Object StatusCode" -# Refresh facturi manual -curl -X POST http://localhost:5003/api/dashboard/refresh-invoices +# Retry comanda din linie de comanda +powershell -Command "Invoke-WebRequest -Uri 'http://localhost/gomag/api/orders/NRCOMANDA/retry' -Method POST -UseBasicParsing | Select-Object -ExpandProperty Content" ``` +#### Deploy pachet Oracle PL/SQL via SSH + +```bash +# Metoda corecta: sqlplus cu fisier .pck (contine ambele: PACKAGE + PACKAGE BODY) +ssh -i ~/.ssh/id_ed25519 -p 22122 gomag@79.119.86.134 \ + "powershell -Command \"echo exit | sqlplus -S VENDING/PAROLA@ROA '@C:\\gomag-vending\\api\\database-scripts\\05_pack_import_parteneri.pck'\"" +# Output asteptat: "Package created." + "Package body created." +``` + +#### Restart serviciu FastAPI via SSH + +Userul `gomag` nu are acces la `nssm` sau `sc` (necesita Administrator). +Metoda disponibila — kill python + relanseaza start.ps1: + +```bash +# 1. Gaseste PID-urile Python +ssh -i ~/.ssh/id_ed25519 -p 22122 gomag@79.119.86.134 \ + "powershell -Command \"Get-Process python -ErrorAction SilentlyContinue | Format-Table Id, CPU -AutoSize\"" + +# 2. Kill + restart (inlocuieste PID1,PID2 cu valorile reale) +ssh -i ~/.ssh/id_ed25519 -p 22122 gomag@79.119.86.134 \ + "powershell -Command \"Stop-Process -Id PID1,PID2 -Force -ErrorAction SilentlyContinue; Start-Sleep 2; cd C:\\gomag-vending; Start-Process powershell -ArgumentList '-NoExit','-File','start.ps1' -WindowStyle Hidden\"" + +# 3. Verifica ca a pornit (asteapta ~5s) +ssh -i ~/.ssh/id_ed25519 -p 22122 gomag@79.119.86.134 \ + "powershell -Command \"Invoke-WebRequest -Uri 'http://localhost/gomag/' -UseBasicParsing | Select-Object StatusCode\"" +``` + +#### Ce NU merge via SSH (userul gomag fara Administrator) + +| Comanda | Eroare | Alternativa | +|---------|--------|-------------| +| `nssm restart GoMagVending` | `Error opening service manager!` | Kill python + Start-Process start.ps1 (vezi mai sus) | +| `sc query` / `sc stop` | `Access is denied` | Nu exista alternativa — necesita acces direct la server | +| `Get-WmiObject Win32_Process` | `Access denied` | `Get-Process` simplu fara CommandLine | +| Pipe `\|` in -Command cu ghilimele nested | `An empty pipe element is not allowed` | Scrie SQL in fisier temporar, copiaza cu scp, ruleaza `@fisier.sql` | +| `&&` (bash syntax) in PowerShell | `The term '&&' is not recognized` | Foloseste `;` (continua indiferent) sau `-Command "cmd1; cmd2"` | +| `-m` flag la `curl` in PowerShell | `Ambiguous parameter name` | Foloseste `Invoke-WebRequest` in loc de curl | +| Here-doc `<< 'EOF'` in PowerShell | `Missing file specification` | Scrie fisierul local, copiaza cu scp | + +#### Rulare SQL ad-hoc prin SSH (fara interactiv) + +PowerShell nu suporta pipe catre sqlplus cu ghilimele complexe. Metoda corecta: + +```bash +# 1. Scrie SQL local +cat > /tmp/query.sql << 'EOF' +SELECT coloana FROM tabel WHERE conditie; +exit +EOF + +# 2. Copiaza pe prod +scp -i ~/.ssh/id_ed25519 -P 22122 /tmp/query.sql "gomag@79.119.86.134:C:/gomag-vending/query.sql" + +# 3. Ruleaza +ssh -i ~/.ssh/id_ed25519 -p 22122 gomag@79.119.86.134 \ + "powershell -Command \"sqlplus -S VENDING/PAROLA@ROA '@C:\\gomag-vending\\query.sql'\"" +``` + +**Nu folosi** `echo 'SQL;' | sqlplus` — PowerShell trateaza `|` diferit si poate esua cu "empty pipe element". + ### Probleme frecvente | Eroare | Cauza | Solutie |