Add systemd unit, requirements.txt and venv setup docs
This commit is contained in:
1 parent
8526a1bc39
commit
cb198120ba
4 files changed
+42
-3
No files matched your search
@@ -1,2 +1,3 @@
|
||||
.env
|
||||
__pycache__/
|
||||
venv/
|
||||
@@ -6,16 +6,19 @@ MJPEG-Stream-Server für die Raspberry-Pi-Kamera. Startet `rpicam-vid` einmalig
|
||||
|
||||
- Raspberry Pi mit angeschlossener Kamera
|
||||
- `rpicam-vid` (rpicam-apps)
|
||||
- Python 3 mit `flask` und optional `python-dotenv`
|
||||
- Python 3 mit venv (`sudo apt install python3-venv`)
|
||||
|
||||
## Installation
|
||||
|
||||
```bash
|
||||
pip install flask python-dotenv
|
||||
python3 -m venv venv
|
||||
venv/bin/pip install -r requirements.txt
|
||||
```
|
||||
|
||||
## Start
|
||||
|
||||
```bash
|
||||
python3 app.py
|
||||
venv/bin/python app.py
|
||||
```
|
||||
|
||||
Danach erreichbar unter:
|
||||
@@ -26,6 +29,23 @@ Danach erreichbar unter:
|
||||
| `http://<host>:8080/stream` | MJPEG-Stream |
|
||||
| `http://<host>:8080/stream.mjpg` | MJPEG-Stream (vehicle-counter kompatibel) |
|
||||
|
||||
## Autostart mit systemd
|
||||
|
||||
Die Unit nutzt den Interpreter aus dem venv (`venv/bin/python`), das Projekt muss also vorher wie oben installiert sein. In `raspi-cam.service` ggf. `User` und die Pfade anpassen. Der User muss Mitglied der Gruppe `video` sein.
|
||||
|
||||
```bash
|
||||
sudo cp raspi-cam.service /etc/systemd/system/
|
||||
sudo systemctl daemon-reload
|
||||
sudo systemctl enable --now raspi-cam
|
||||
```
|
||||
|
||||
Status und Logs:
|
||||
|
||||
```bash
|
||||
systemctl status raspi-cam
|
||||
journalctl -u raspi-cam -f
|
||||
```
|
||||
|
||||
## Konfiguration
|
||||
|
||||
Die Konfiguration erfolgt über Umgebungsvariablen oder eine `.env`-Datei im Projektverzeichnis.
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
[Unit]
|
||||
Description=Raspberry Pi Camera MJPEG Stream Server
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
User=joachim
|
||||
Group=video
|
||||
WorkingDirectory=/home/joachim/git/raspi-cam
|
||||
ExecStart=/home/joachim/git/raspi-cam/venv/bin/python /home/joachim/git/raspi-cam/app.py
|
||||
Restart=always
|
||||
RestartSec=3
|
||||
Environment=PYTHONUNBUFFERED=1
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
@@ -0,0 +1,2 @@
|
||||
flask
|
||||
python-dotenv
|
||||
Reference in new issue
Block a user