This commit is contained in:
@@ -0,0 +1,77 @@
|
||||
name: Deploy to Windows VPS
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
workflow_dispatch: # Ermöglicht manuelles Triggern
|
||||
|
||||
jobs:
|
||||
deploy:
|
||||
runs-on: windows-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout Code
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Deploy to VPS
|
||||
shell: powershell
|
||||
run: |
|
||||
Write-Host "Starting deployment..." -ForegroundColor Green
|
||||
|
||||
# Navigiere zum Deployment-Verzeichnis
|
||||
Set-Location "C:\TradingBot\placeorder"
|
||||
|
||||
# Git Pull (neueste Änderungen holen)
|
||||
Write-Host "Pulling latest changes from Git..." -ForegroundColor Cyan
|
||||
git pull origin main
|
||||
|
||||
# Optional: Python Dependencies aktualisieren
|
||||
Write-Host "Updating Python dependencies..." -ForegroundColor Cyan
|
||||
pip install --upgrade -r requirements.txt -ErrorAction SilentlyContinue
|
||||
|
||||
# Deployment-Skript ausführen
|
||||
Write-Host "Running deployment script..." -ForegroundColor Cyan
|
||||
.\deploy.ps1
|
||||
|
||||
Write-Host "Deployment completed successfully!" -ForegroundColor Green
|
||||
|
||||
- name: Verify Deployment
|
||||
shell: powershell
|
||||
run: |
|
||||
Write-Host "Verifying deployment..." -ForegroundColor Yellow
|
||||
|
||||
# Prüfe ob Trading Bot Dateien existieren
|
||||
$files = @(
|
||||
"C:\TradingBot\placeorder\TradingBot_V1.6_Adaptive_Complete_CORRECTED.ipynb",
|
||||
"C:\TradingBot\placeorder\trading_dashboard.py",
|
||||
"C:\TradingBot\placeorder\trading_database.py"
|
||||
)
|
||||
|
||||
foreach ($file in $files) {
|
||||
if (Test-Path $file) {
|
||||
Write-Host "✓ $file exists" -ForegroundColor Green
|
||||
} else {
|
||||
Write-Host "✗ $file missing!" -ForegroundColor Red
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
|
||||
Write-Host "All files verified!" -ForegroundColor Green
|
||||
|
||||
- name: Restart Services
|
||||
shell: powershell
|
||||
run: |
|
||||
Write-Host "Restarting services..." -ForegroundColor Cyan
|
||||
|
||||
# Restart Trading Dashboard Service (falls als Service läuft)
|
||||
if (Get-Service -Name "TradingDashboard" -ErrorAction SilentlyContinue) {
|
||||
Restart-Service -Name "TradingDashboard" -Force
|
||||
Write-Host "✓ TradingDashboard service restarted" -ForegroundColor Green
|
||||
} else {
|
||||
Write-Host "ℹ TradingDashboard service not found (might not be installed yet)" -ForegroundColor Yellow
|
||||
}
|
||||
|
||||
Write-Host "Deployment process finished!" -ForegroundColor Green
|
||||
@@ -0,0 +1,475 @@
|
||||
# Gitea Actions - Automatisches Deployment Setup
|
||||
|
||||
Diese Anleitung zeigt dir, wie du **Gitea Actions** mit einem **Self-hosted Runner** auf deinem Windows VPS einrichtest, um automatische Deployments bei jedem Git Push zu ermöglichen.
|
||||
|
||||
## Übersicht
|
||||
|
||||
**Was wird eingerichtet:**
|
||||
1. Gitea Actions auf deiner Synology NAS (Gitea Server)
|
||||
2. Self-hosted Runner auf deinem Windows VPS
|
||||
3. Automatisches Deployment bei jedem Push auf `main` Branch
|
||||
|
||||
**Workflow:**
|
||||
```
|
||||
[Git Push auf NAS] → [Gitea Webhook] → [Runner auf Windows VPS] → [Deploy Skript ausführen] → [Bot aktualisiert]
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## TEIL 1: Gitea Actions auf Synology NAS aktivieren
|
||||
|
||||
### Schritt 1: Gitea Konfiguration prüfen
|
||||
|
||||
**Via SSH auf Synology:**
|
||||
|
||||
```bash
|
||||
# SSH zur Synology
|
||||
ssh admin@your-synology-ip
|
||||
|
||||
# Navigiere zu Gitea-Konfiguration
|
||||
# (Pfad variiert je nach Installation)
|
||||
cd /volume1/docker/gitea
|
||||
# ODER
|
||||
cd /var/packages/gitea/target
|
||||
|
||||
# Finde app.ini
|
||||
find / -name "app.ini" 2>/dev/null | grep gitea
|
||||
```
|
||||
|
||||
### Schritt 2: Gitea Actions aktivieren
|
||||
|
||||
**Bearbeite `app.ini`:**
|
||||
|
||||
```ini
|
||||
[actions]
|
||||
ENABLED = true
|
||||
DEFAULT_ACTIONS_URL = https://gitea.com
|
||||
```
|
||||
|
||||
**Gitea neustarten:**
|
||||
|
||||
```bash
|
||||
# Docker Gitea
|
||||
docker restart gitea
|
||||
|
||||
# ODER via Synology Package Manager
|
||||
# Stoppe und starte Gitea über die Web-Oberfläche
|
||||
```
|
||||
|
||||
### Schritt 3: Gitea Actions im Web-UI prüfen
|
||||
|
||||
1. Öffne deine Gitea-Instanz im Browser
|
||||
2. Gehe zu deinem Repository `placeorder`
|
||||
3. Klicke auf **Settings** → **Actions**
|
||||
4. Aktiviere Actions für das Repository
|
||||
|
||||
---
|
||||
|
||||
## TEIL 2: Gitea Runner auf Windows VPS installieren
|
||||
|
||||
### Schritt 1: Runner-Binary herunterladen
|
||||
|
||||
**Öffne PowerShell als Administrator auf deinem Windows VPS:**
|
||||
|
||||
```powershell
|
||||
# Erstelle Verzeichnis für Runner
|
||||
New-Item -ItemType Directory -Path "C:\Gitea-Runner" -Force
|
||||
Set-Location "C:\Gitea-Runner"
|
||||
|
||||
# Download Gitea Runner (Windows AMD64)
|
||||
# Prüfe aktuelle Version: https://dl.gitea.com/act_runner/
|
||||
$runnerVersion = "0.2.11" # Passe Version an
|
||||
$downloadUrl = "https://dl.gitea.com/act_runner/$runnerVersion/act_runner-$runnerVersion-windows-amd64.exe"
|
||||
|
||||
Invoke-WebRequest -Uri $downloadUrl -OutFile "act_runner.exe"
|
||||
|
||||
Write-Host "Gitea Runner downloaded successfully!" -ForegroundColor Green
|
||||
```
|
||||
|
||||
**Alternative: Manueller Download**
|
||||
|
||||
1. Gehe zu: https://dl.gitea.com/act_runner/
|
||||
2. Wähle neueste Version
|
||||
3. Download: `act_runner-{version}-windows-amd64.exe`
|
||||
4. Umbenennen zu `act_runner.exe`
|
||||
5. Kopiere nach `C:\Gitea-Runner\`
|
||||
|
||||
### Schritt 2: Runner registrieren
|
||||
|
||||
**1. Registration Token von Gitea holen:**
|
||||
|
||||
Gehe zu deiner Gitea-Instanz:
|
||||
- **Repository Settings** → **Actions** → **Runners** → **Create new Runner**
|
||||
- Kopiere den **Registration Token**
|
||||
|
||||
**2. Runner registrieren:**
|
||||
|
||||
```powershell
|
||||
Set-Location "C:\Gitea-Runner"
|
||||
|
||||
# Runner registrieren
|
||||
.\act_runner.exe register `
|
||||
--instance "http://your-synology-ip:3000" `
|
||||
--token "YOUR_REGISTRATION_TOKEN_HERE" `
|
||||
--name "windows-vps-runner" `
|
||||
--labels "windows-latest"
|
||||
|
||||
# Bei Erfolg wird eine .runner Datei erstellt
|
||||
```
|
||||
|
||||
**Interaktive Fragen während Registration:**
|
||||
|
||||
- **Runner name:** `windows-vps-runner`
|
||||
- **Runner labels:** `windows-latest`
|
||||
- **Custom labels:** (leer lassen)
|
||||
|
||||
**Wichtig:** Ersetze:
|
||||
- `your-synology-ip:3000` mit deiner Gitea-URL (z.B. `http://192.168.1.50:3000`)
|
||||
- `YOUR_REGISTRATION_TOKEN_HERE` mit dem Token aus Gitea
|
||||
|
||||
### Schritt 3: Runner konfigurieren
|
||||
|
||||
**Bearbeite `.runner` (optional):**
|
||||
|
||||
```bash
|
||||
notepad .runner
|
||||
```
|
||||
|
||||
Standard-Konfiguration ist meist ausreichend.
|
||||
|
||||
### Schritt 4: Runner als Windows Service einrichten (EMPFOHLEN)
|
||||
|
||||
**Mit NSSM (Non-Sucking Service Manager):**
|
||||
|
||||
**1. NSSM herunterladen:**
|
||||
|
||||
```powershell
|
||||
# Download NSSM
|
||||
$nssmUrl = "https://nssm.cc/ci/nssm-2.24-101-g897c7ad.zip"
|
||||
Invoke-WebRequest -Uri $nssmUrl -OutFile "C:\Gitea-Runner\nssm.zip"
|
||||
|
||||
# Entpacke NSSM
|
||||
Expand-Archive -Path "C:\Gitea-Runner\nssm.zip" -DestinationPath "C:\Gitea-Runner\nssm"
|
||||
|
||||
# Navigiere zu NSSM Binary
|
||||
Set-Location "C:\Gitea-Runner\nssm\nssm-2.24-101-g897c7ad\win64"
|
||||
```
|
||||
|
||||
**2. Service erstellen:**
|
||||
|
||||
```powershell
|
||||
# Service installieren
|
||||
.\nssm.exe install GiteaRunner
|
||||
|
||||
# Im NSSM GUI konfigurieren:
|
||||
# - Path: C:\Gitea-Runner\act_runner.exe
|
||||
# - Startup directory: C:\Gitea-Runner
|
||||
# - Arguments: daemon
|
||||
```
|
||||
|
||||
**NSSM GUI Konfiguration:**
|
||||
|
||||
- **Application Tab:**
|
||||
- Path: `C:\Gitea-Runner\act_runner.exe`
|
||||
- Startup directory: `C:\Gitea-Runner`
|
||||
- Arguments: `daemon`
|
||||
|
||||
- **Details Tab:**
|
||||
- Display name: `Gitea Runner`
|
||||
- Description: `Gitea Actions Self-hosted Runner for Windows VPS`
|
||||
|
||||
- **Log on Tab:**
|
||||
- Account: Dein Windows User (mit Admin-Rechten)
|
||||
|
||||
- **I/O Tab:**
|
||||
- Output (stdout): `C:\Gitea-Runner\runner_stdout.log`
|
||||
- Error (stderr): `C:\Gitea-Runner\runner_stderr.log`
|
||||
|
||||
**3. Service starten:**
|
||||
|
||||
```powershell
|
||||
# Service starten
|
||||
Start-Service GiteaRunner
|
||||
|
||||
# Service Status prüfen
|
||||
Get-Service GiteaRunner
|
||||
|
||||
# Logs prüfen
|
||||
Get-Content "C:\Gitea-Runner\runner_stdout.log" -Tail 20
|
||||
```
|
||||
|
||||
**Alternative: Runner manuell starten (nur zum Testen):**
|
||||
|
||||
```powershell
|
||||
Set-Location "C:\Gitea-Runner"
|
||||
.\act_runner.exe daemon
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## TEIL 3: Repository für Deployment vorbereiten
|
||||
|
||||
### Schritt 1: Code auf Windows VPS klonen
|
||||
|
||||
**Auf Windows VPS (PowerShell):**
|
||||
|
||||
```powershell
|
||||
# Erstelle TradingBot Verzeichnis
|
||||
New-Item -ItemType Directory -Path "C:\TradingBot" -Force
|
||||
Set-Location "C:\TradingBot"
|
||||
|
||||
# Git Repository klonen
|
||||
git clone http://your-synology-ip:3000/your-username/placeorder.git
|
||||
|
||||
# Navigiere ins Repo
|
||||
cd placeorder
|
||||
|
||||
# Prüfe Status
|
||||
git status
|
||||
```
|
||||
|
||||
**Wichtig:** Ersetze:
|
||||
- `your-synology-ip:3000` mit deiner Gitea-URL
|
||||
- `your-username` mit deinem Gitea-Username
|
||||
|
||||
### Schritt 2: Git Credentials speichern (optional)
|
||||
|
||||
**Damit Git nicht jedes Mal nach Passwort fragt:**
|
||||
|
||||
```powershell
|
||||
# Git Credential Helper aktivieren
|
||||
git config --global credential.helper store
|
||||
|
||||
# Beim nächsten Pull/Push Credentials eingeben
|
||||
git pull
|
||||
# Username: dein-gitea-username
|
||||
# Password: dein-gitea-password
|
||||
|
||||
# Credentials werden gespeichert
|
||||
```
|
||||
|
||||
**Oder mit SSH Keys (empfohlen):**
|
||||
|
||||
```powershell
|
||||
# SSH Key generieren
|
||||
ssh-keygen -t ed25519 -C "your_email@example.com"
|
||||
# Speichere unter: C:\Users\YourUser\.ssh\id_ed25519
|
||||
|
||||
# Public Key anzeigen
|
||||
Get-Content "$env:USERPROFILE\.ssh\id_ed25519.pub"
|
||||
|
||||
# Kopiere den Key und füge ihn in Gitea ein:
|
||||
# Gitea → Settings → SSH / GPG Keys → Add Key
|
||||
```
|
||||
|
||||
Dann ändere Remote-URL:
|
||||
```powershell
|
||||
git remote set-url origin git@your-synology-ip:your-username/placeorder.git
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## TEIL 4: Testen und Troubleshooting
|
||||
|
||||
### Test 1: Workflow manuell triggern
|
||||
|
||||
1. Gehe zu Gitea → Repository `placeorder`
|
||||
2. Klicke auf **Actions**
|
||||
3. Wähle den Workflow **"Deploy to Windows VPS"**
|
||||
4. Klicke auf **Run workflow** → **Run**
|
||||
|
||||
Prüfe die Logs in Echtzeit.
|
||||
|
||||
### Test 2: Deployment via Git Push
|
||||
|
||||
**Auf deinem Mac (oder lokal):**
|
||||
|
||||
```bash
|
||||
cd "/Users/sebastianfrohlich/Library/Mobile Documents/com~apple~CloudDocs/Jupyter Notebooks/FinancialTrading/PlaceOrder/placeorder"
|
||||
|
||||
# Kleine Änderung machen
|
||||
echo "# Test" >> README.md
|
||||
|
||||
# Commit & Push
|
||||
git add README.md
|
||||
git commit -m "Test: Trigger Gitea Actions"
|
||||
git push origin main
|
||||
```
|
||||
|
||||
**Auf Gitea (Web-UI):**
|
||||
- Gehe zu **Actions** Tab
|
||||
- Du solltest den Workflow laufen sehen
|
||||
|
||||
**Auf Windows VPS:**
|
||||
- Prüfe Logs: `C:\Gitea-Runner\runner_stdout.log`
|
||||
|
||||
### Troubleshooting
|
||||
|
||||
#### Problem: Runner erscheint nicht in Gitea
|
||||
|
||||
**Lösung:**
|
||||
|
||||
```powershell
|
||||
# Prüfe Runner Service
|
||||
Get-Service GiteaRunner
|
||||
|
||||
# Prüfe Logs
|
||||
Get-Content "C:\Gitea-Runner\runner_stdout.log" -Tail 50
|
||||
|
||||
# Neustart
|
||||
Restart-Service GiteaRunner
|
||||
```
|
||||
|
||||
#### Problem: Workflow startet nicht
|
||||
|
||||
**Lösung:**
|
||||
|
||||
1. Prüfe ob Runner online ist:
|
||||
- Gitea → Repository → Settings → Actions → Runners
|
||||
- Sollte "Online" zeigen
|
||||
|
||||
2. Prüfe Workflow-Syntax:
|
||||
- `.gitea/workflows/deploy.yml` auf Syntax-Fehler prüfen
|
||||
|
||||
3. Prüfe Labels:
|
||||
- Workflow verwendet `runs-on: windows-latest`
|
||||
- Runner muss Label `windows-latest` haben
|
||||
|
||||
#### Problem: Git Pull schlägt fehl
|
||||
|
||||
**Lösung:**
|
||||
|
||||
```powershell
|
||||
# Prüfe Git-Konfiguration
|
||||
cd C:\TradingBot\placeorder
|
||||
git remote -v
|
||||
git status
|
||||
|
||||
# Setze Origin URL neu
|
||||
git remote set-url origin http://your-synology-ip:3000/your-username/placeorder.git
|
||||
|
||||
# Teste Pull
|
||||
git pull origin main
|
||||
```
|
||||
|
||||
#### Problem: Permission Denied
|
||||
|
||||
**Lösung:**
|
||||
|
||||
1. NSSM Service unter richtigem User-Account laufen lassen
|
||||
2. User muss Schreibrechte auf `C:\TradingBot\placeorder` haben
|
||||
3. PowerShell als Administrator ausführen
|
||||
|
||||
---
|
||||
|
||||
## TEIL 5: Workflow-Anpassungen
|
||||
|
||||
### Custom Deployment-Pfade
|
||||
|
||||
**Falls dein Trading Bot woanders liegt:**
|
||||
|
||||
Bearbeite `.gitea/workflows/deploy.yml`:
|
||||
|
||||
```yaml
|
||||
- name: Deploy to VPS
|
||||
shell: powershell
|
||||
run: |
|
||||
Set-Location "D:\MyCustomPath\placeorder" # Ändere hier
|
||||
git pull origin main
|
||||
.\deploy.ps1
|
||||
```
|
||||
|
||||
### Deployment nur auf bestimmten Branches
|
||||
|
||||
```yaml
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
- production # Füge weitere Branches hinzu
|
||||
```
|
||||
|
||||
### Notifications bei Fehler
|
||||
|
||||
Füge Schritt hinzu:
|
||||
|
||||
```yaml
|
||||
- name: Notify on Failure
|
||||
if: failure()
|
||||
shell: powershell
|
||||
run: |
|
||||
# Sende Telegram-Nachricht oder Email
|
||||
Write-Host "Deployment failed! Sending notification..." -ForegroundColor Red
|
||||
# Dein Notification-Code hier
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Checkliste
|
||||
|
||||
- [ ] Gitea Actions auf Synology aktiviert
|
||||
- [ ] Gitea Runner Binary heruntergeladen (`C:\Gitea-Runner\act_runner.exe`)
|
||||
- [ ] Runner registriert mit Gitea
|
||||
- [ ] Runner als Windows Service installiert (NSSM)
|
||||
- [ ] Service läuft (`Get-Service GiteaRunner` zeigt "Running")
|
||||
- [ ] Repository auf Windows VPS geklont (`C:\TradingBot\placeorder`)
|
||||
- [ ] Git Credentials konfiguriert (Store oder SSH)
|
||||
- [ ] Workflow-Datei committed (`.gitea/workflows/deploy.yml`)
|
||||
- [ ] Deployment-Skript vorhanden (`deploy.ps1`)
|
||||
- [ ] Test-Push durchgeführt und Workflow erfolgreich
|
||||
- [ ] Runner erscheint als "Online" in Gitea
|
||||
|
||||
---
|
||||
|
||||
## Nützliche Befehle
|
||||
|
||||
**Windows VPS (PowerShell):**
|
||||
|
||||
```powershell
|
||||
# Runner Status
|
||||
Get-Service GiteaRunner
|
||||
Get-Content "C:\Gitea-Runner\runner_stdout.log" -Tail 50
|
||||
|
||||
# Runner neustarten
|
||||
Restart-Service GiteaRunner
|
||||
|
||||
# Deployment manuell triggern
|
||||
cd C:\TradingBot\placeorder
|
||||
git pull origin main
|
||||
.\deploy.ps1
|
||||
|
||||
# Prozesse prüfen
|
||||
Get-Process | Where-Object {$_.ProcessName -like "*act_runner*"}
|
||||
```
|
||||
|
||||
**Synology NAS:**
|
||||
|
||||
```bash
|
||||
# Gitea Logs prüfen
|
||||
docker logs gitea -f
|
||||
|
||||
# Gitea neustarten
|
||||
docker restart gitea
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Weiterführende Links
|
||||
|
||||
- **Gitea Actions Docs:** https://docs.gitea.com/next/usage/actions/overview
|
||||
- **Act Runner Releases:** https://dl.gitea.com/act_runner/
|
||||
- **NSSM Download:** https://nssm.cc/download
|
||||
|
||||
---
|
||||
|
||||
## Support & Hilfe
|
||||
|
||||
Bei Problemen:
|
||||
|
||||
1. Prüfe Runner-Logs: `C:\Gitea-Runner\runner_stdout.log`
|
||||
2. Prüfe Workflow-Logs in Gitea Web-UI (Actions Tab)
|
||||
3. Prüfe Windows Event Viewer für Service-Fehler
|
||||
|
||||
---
|
||||
|
||||
Du bist jetzt bereit für automatische Deployments! Bei jedem `git push` wird dein Trading Bot auf dem Windows VPS automatisch aktualisiert.
|
||||
+162
@@ -0,0 +1,162 @@
|
||||
# ========================================
|
||||
# Trading Bot Deployment Script
|
||||
# Windows VPS Deployment Automation
|
||||
# ========================================
|
||||
|
||||
Write-Host "========================================" -ForegroundColor Cyan
|
||||
Write-Host " Trading Bot Deployment Script v1.0" -ForegroundColor Cyan
|
||||
Write-Host "========================================" -ForegroundColor Cyan
|
||||
Write-Host ""
|
||||
|
||||
# Deployment-Verzeichnis
|
||||
$deployPath = "C:\TradingBot\placeorder"
|
||||
$timestamp = Get-Date -Format "yyyyMMdd_HHmmss"
|
||||
$backupPath = "C:\TradingBot\backups\backup_$timestamp"
|
||||
|
||||
# ========================================
|
||||
# SCHRITT 1: Backup erstellen
|
||||
# ========================================
|
||||
Write-Host "[1/5] Creating backup..." -ForegroundColor Yellow
|
||||
|
||||
# Erstelle Backup-Verzeichnis falls nicht vorhanden
|
||||
if (!(Test-Path "C:\TradingBot\backups")) {
|
||||
New-Item -ItemType Directory -Path "C:\TradingBot\backups" -Force | Out-Null
|
||||
}
|
||||
|
||||
# Backup kritischer Dateien
|
||||
$filesToBackup = @(
|
||||
"trading_bot.db",
|
||||
"telegram_config.json"
|
||||
)
|
||||
|
||||
New-Item -ItemType Directory -Path $backupPath -Force | Out-Null
|
||||
|
||||
foreach ($file in $filesToBackup) {
|
||||
if (Test-Path $file) {
|
||||
Copy-Item $file -Destination "$backupPath\$file" -Force
|
||||
Write-Host " ✓ Backed up: $file" -ForegroundColor Green
|
||||
}
|
||||
}
|
||||
|
||||
Write-Host " ✓ Backup created at: $backupPath" -ForegroundColor Green
|
||||
Write-Host ""
|
||||
|
||||
# ========================================
|
||||
# SCHRITT 2: Git Pull (bereits von Workflow erledigt)
|
||||
# ========================================
|
||||
Write-Host "[2/5] Verifying Git repository..." -ForegroundColor Yellow
|
||||
|
||||
if (Test-Path ".git") {
|
||||
$branch = git rev-parse --abbrev-ref HEAD
|
||||
$commit = git rev-parse --short HEAD
|
||||
Write-Host " ✓ Branch: $branch" -ForegroundColor Green
|
||||
Write-Host " ✓ Commit: $commit" -ForegroundColor Green
|
||||
} else {
|
||||
Write-Host " ✗ No Git repository found!" -ForegroundColor Red
|
||||
exit 1
|
||||
}
|
||||
|
||||
Write-Host ""
|
||||
|
||||
# ========================================
|
||||
# SCHRITT 3: Python Dependencies prüfen/aktualisieren
|
||||
# ========================================
|
||||
Write-Host "[3/5] Checking Python dependencies..." -ForegroundColor Yellow
|
||||
|
||||
# Prüfe ob requirements.txt existiert
|
||||
if (Test-Path "requirements.txt") {
|
||||
Write-Host " Installing/Updating dependencies from requirements.txt..." -ForegroundColor Cyan
|
||||
pip install --upgrade -r requirements.txt --quiet
|
||||
if ($LASTEXITCODE -eq 0) {
|
||||
Write-Host " ✓ Dependencies installed successfully" -ForegroundColor Green
|
||||
} else {
|
||||
Write-Host " ⚠ Some dependencies might have failed" -ForegroundColor Yellow
|
||||
}
|
||||
} else {
|
||||
Write-Host " ℹ No requirements.txt found, installing common packages..." -ForegroundColor Cyan
|
||||
pip install --upgrade streamlit plotly pandas MetaTrader5 --quiet
|
||||
Write-Host " ✓ Common packages installed" -ForegroundColor Green
|
||||
}
|
||||
|
||||
Write-Host ""
|
||||
|
||||
# ========================================
|
||||
# SCHRITT 4: Services neu starten
|
||||
# ========================================
|
||||
Write-Host "[4/5] Restarting services..." -ForegroundColor Yellow
|
||||
|
||||
# Trading Dashboard Service
|
||||
$dashboardService = Get-Service -Name "TradingDashboard" -ErrorAction SilentlyContinue
|
||||
if ($dashboardService) {
|
||||
Write-Host " Restarting TradingDashboard service..." -ForegroundColor Cyan
|
||||
Restart-Service -Name "TradingDashboard" -Force
|
||||
Start-Sleep -Seconds 3
|
||||
|
||||
$status = (Get-Service -Name "TradingDashboard").Status
|
||||
if ($status -eq "Running") {
|
||||
Write-Host " ✓ TradingDashboard is running" -ForegroundColor Green
|
||||
} else {
|
||||
Write-Host " ✗ TradingDashboard failed to start!" -ForegroundColor Red
|
||||
}
|
||||
} else {
|
||||
Write-Host " ℹ TradingDashboard service not installed (manual start required)" -ForegroundColor Yellow
|
||||
}
|
||||
|
||||
# Optional: Prozesse neustarten falls kein Service installiert
|
||||
$streamlitProcesses = Get-Process | Where-Object {$_.ProcessName -like "*streamlit*"}
|
||||
if ($streamlitProcesses) {
|
||||
Write-Host " Found running Streamlit processes, restarting..." -ForegroundColor Cyan
|
||||
$streamlitProcesses | Stop-Process -Force
|
||||
Start-Sleep -Seconds 2
|
||||
|
||||
# Starte Streamlit neu (im Hintergrund)
|
||||
Start-Process powershell -ArgumentList "-NoExit", "-Command", "cd '$deployPath'; streamlit run trading_dashboard.py --server.port 8501 --server.address 0.0.0.0" -WindowStyle Minimized
|
||||
Write-Host " ✓ Streamlit restarted" -ForegroundColor Green
|
||||
}
|
||||
|
||||
Write-Host ""
|
||||
|
||||
# ========================================
|
||||
# SCHRITT 5: Deployment-Verifikation
|
||||
# ========================================
|
||||
Write-Host "[5/5] Verifying deployment..." -ForegroundColor Yellow
|
||||
|
||||
$criticalFiles = @(
|
||||
"TradingBot_V1.6_Adaptive_Complete_CORRECTED.ipynb",
|
||||
"trading_dashboard.py",
|
||||
"trading_database.py"
|
||||
)
|
||||
|
||||
$allFilesExist = $true
|
||||
foreach ($file in $criticalFiles) {
|
||||
if (Test-Path $file) {
|
||||
Write-Host " ✓ $file" -ForegroundColor Green
|
||||
} else {
|
||||
Write-Host " ✗ $file missing!" -ForegroundColor Red
|
||||
$allFilesExist = $false
|
||||
}
|
||||
}
|
||||
|
||||
Write-Host ""
|
||||
|
||||
# ========================================
|
||||
# DEPLOYMENT SUMMARY
|
||||
# ========================================
|
||||
Write-Host "========================================" -ForegroundColor Cyan
|
||||
Write-Host " DEPLOYMENT SUMMARY" -ForegroundColor Cyan
|
||||
Write-Host "========================================" -ForegroundColor Cyan
|
||||
|
||||
if ($allFilesExist) {
|
||||
Write-Host "Status: SUCCESS" -ForegroundColor Green
|
||||
Write-Host "Timestamp: $(Get-Date -Format 'yyyy-MM-dd HH:mm:ss')" -ForegroundColor White
|
||||
Write-Host "Backup Location: $backupPath" -ForegroundColor White
|
||||
Write-Host "Dashboard URL: http://localhost:8501" -ForegroundColor Cyan
|
||||
Write-Host ""
|
||||
Write-Host "✓ Deployment completed successfully!" -ForegroundColor Green
|
||||
exit 0
|
||||
} else {
|
||||
Write-Host "Status: FAILED" -ForegroundColor Red
|
||||
Write-Host "Some critical files are missing!" -ForegroundColor Red
|
||||
Write-Host "Check the logs above for details." -ForegroundColor Yellow
|
||||
exit 1
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
# Trading Bot Dependencies
|
||||
# Python 3.8+
|
||||
|
||||
# Core Trading & Data
|
||||
MetaTrader5>=5.0.45
|
||||
pandas>=2.0.0
|
||||
numpy>=1.24.0
|
||||
|
||||
# Visualization & Dashboard
|
||||
streamlit>=1.31.0
|
||||
plotly>=5.18.0
|
||||
|
||||
# Database
|
||||
sqlite3-python>=1.0.0 # Usually built-in
|
||||
|
||||
# Utilities
|
||||
python-dotenv>=1.0.0
|
||||
requests>=2.31.0
|
||||
|
||||
# Optional: Jupyter Notebook support
|
||||
jupyter>=1.0.0
|
||||
notebook>=7.0.0
|
||||
ipykernel>=6.25.0
|
||||
Reference in New Issue
Block a user