logs: Add ttyd on /ttyd endpoint

This commit is contained in:
Samuel Ortion 2022-08-21 11:50:33 +02:00
parent 6d44735ef5
commit 8a192ea2b2
3 changed files with 50 additions and 1 deletions

View File

@ -33,7 +33,7 @@ BRANCH=dev ./install.sh
```bash ```bash
sudo apt-get update sudo apt-get update
sudo apt-get install python3-dev python3-pip sudo apt-get install python3-dev python3-pip python3-venv
sudo pip3 install --upgrade pip sudo pip3 install --upgrade pip
``` ```
@ -272,3 +272,28 @@ sudo crontab -e
``` ```
(This updates the certicates every first day of the month, feel free to adapt to your needs.) (This updates the certicates every first day of the month, feel free to adapt to your needs.)
## Setup ttyd to stream audio to webapp
Change to a dedicated folder, build and install ttyd:
```bash
cd /opt
sudo wget wget https://github.com/tsl0922/ttyd/releases/download/1.7.1/ttyd.x86_64 # Change to your architecture and get last version
sudo mv ttyd.x86_64 ttyd
sudo chmod +x ttyd
```
Set up birdnet_ttyd systemd service to start as a daemon:
```bash
# Copy service template
sudo cp ./daemon/systemd/templates/birdnet_ttyd.service /etc/systemd/system/birdnet_ttyd.service
# Edit template and adapt placeholders
sudo vim /etc/systemd/system/birdnet_ttyd.service
# Enable and start ttyd service
sudo systemctl daemon-reload
sudo systemctl enable --now birdnet_ttyd.service
```
Then go to [https://birdnet.lan/ttyd](https://birdnet.lan/ttyd) and start streaming logs.

View File

@ -0,0 +1,14 @@
[Unit]
Description=BirdNET-stream logs
After=syslog.target
After=network.target
[Service]
User=<USER>
Group=<GROUP>
ExecStart=/opt/ttyd -p 7681 -c birdnet:secret -t disableReconnect=true --readonly journalctl -feu birdnet_\*
Restart=always
Type=simple
[Install]
WantedBy=multi-user.target

View File

@ -51,6 +51,16 @@ server {
proxy_pass http://localhost:8000/stream; proxy_pass http://localhost:8000/stream;
} }
location ~ ^/ttyd(.*)$ {
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_pass http://127.0.0.1:7681/$1;
}
access_log /var/log/nginx/birdnet/birdnet-access.log; access_log /var/log/nginx/birdnet/birdnet-access.log;
error_log /var/log/nginx/birdnet/birdnet-error.log error; error_log /var/log/nginx/birdnet/birdnet-error.log error;
} }