106 lines
2.2 KiB
Markdown
106 lines
2.2 KiB
Markdown
# Deployment-Anleitung für ypchat.net
|
|
|
|
## Voraussetzungen
|
|
|
|
- Die Anwendung muss nach `/opt/ypchat` kopiert werden
|
|
- Node.js muss installiert sein
|
|
- Apache muss konfiguriert sein
|
|
|
|
## Schritte
|
|
|
|
### 1. Anwendung nach /opt/ypchat kopieren
|
|
|
|
```bash
|
|
# Als root oder mit sudo
|
|
sudo mkdir -p /opt/ypchat
|
|
sudo cp -r /home/torsten/Programs/YpChat/* /opt/ypchat/
|
|
sudo chown -R www-data:www-data /opt/ypchat
|
|
```
|
|
|
|
### 2. Installation durchführen
|
|
|
|
```bash
|
|
cd /opt/ypchat
|
|
sudo -u www-data ./install.sh
|
|
```
|
|
|
|
### 3. Service installieren
|
|
|
|
```bash
|
|
cd /opt/ypchat
|
|
sudo ./install-service-ypchat.sh
|
|
```
|
|
|
|
### 4. Alten Service stoppen
|
|
|
|
```bash
|
|
sudo systemctl stop ypchat
|
|
sudo systemctl disable ypchat # Optional: Alten Service deaktivieren
|
|
```
|
|
|
|
### 5. Neuen Service starten
|
|
|
|
```bash
|
|
sudo systemctl start ypchat
|
|
sudo systemctl status ypchat
|
|
```
|
|
|
|
### 6. Logs prüfen
|
|
|
|
```bash
|
|
sudo journalctl -u ypchat -f
|
|
```
|
|
|
|
## Troubleshooting
|
|
|
|
## Auto-Rollout mit Gitea
|
|
|
|
Der Workflow `.gitea/workflows/deploy.yml` startet bei Push auf `main` per SSH das Server-Skript `/usr/local/bin/actualize-singlechat.sh`. Das Skript wird vom Workflow vor dem Start nach `/usr/local/bin` installiert.
|
|
|
|
Gitea-Konfiguration:
|
|
|
|
- Variables: `SSH_HOST`, `SSH_PORT`, `SSH_USER`
|
|
- Secret: `PROD_SSH_KEY_B64` mit dem base64-kodierten privaten Deploy-Key
|
|
|
|
Server-Skript manuell testen:
|
|
|
|
```bash
|
|
sudo install -m 755 scripts/actualize-singlechat.sh /usr/local/bin/actualize-singlechat.sh
|
|
```
|
|
|
|
Das Skript aktualisiert `/opt/ypchat`, baut den Client neu und startet `ypchat` per systemd neu.
|
|
|
|
### Service startet nicht
|
|
|
|
```bash
|
|
# Prüfe Logs
|
|
sudo journalctl -u ypchat -n 50
|
|
|
|
# Prüfe ob Node.js verfügbar ist
|
|
which node
|
|
/usr/bin/node --version
|
|
|
|
# Prüfe ob .env existiert
|
|
ls -la /opt/ypchat/.env
|
|
cat /opt/ypchat/.env
|
|
```
|
|
|
|
### Alte Seite wird noch angezeigt
|
|
|
|
1. Prüfe ob der neue Service läuft: `sudo systemctl status ypchat`
|
|
2. Prüfe ob Port 4000 belegt ist: `sudo lsof -i :4000`
|
|
3. Prüfe Apache-Logs: `sudo tail -f /var/log/apache2/error.log`
|
|
4. Apache neu laden: `sudo systemctl reload apache2`
|
|
|
|
### Gebaute Dateien fehlen
|
|
|
|
```bash
|
|
# Prüfe ob dist existiert
|
|
ls -la /opt/ypchat/docroot/dist
|
|
|
|
# Falls nicht, baue neu:
|
|
cd /opt/ypchat
|
|
sudo -u www-data npm run build
|
|
sudo -u www-data cp -r client/dist docroot/
|
|
```
|