server: split uvc helper service
This commit is contained in:
parent
7d35115d1a
commit
83b34a1b92
10
scripts/daemon/lesavka-uvc.sh
Normal file
10
scripts/daemon/lesavka-uvc.sh
Normal file
@ -0,0 +1,10 @@
|
||||
#!/usr/bin/env bash
|
||||
# scripts/daemon/lesavka-uvc.sh - launch UVC control helper as a standalone service
|
||||
set -euo pipefail
|
||||
|
||||
DEV=${LESAVKA_UVC_DEV:-/dev/v4l/by-path/platform-1000480000.usb-video-index0}
|
||||
if [[ ! -e "$DEV" ]]; then
|
||||
DEV=/dev/video0
|
||||
fi
|
||||
|
||||
exec /usr/local/bin/lesavka-uvc --device "$DEV"
|
||||
@ -137,6 +137,7 @@ echo "==> 5. Install binaries"
|
||||
sudo install -Dm755 "$SRC_DIR/server/target/release/lesavka-server" /usr/local/bin/lesavka-server
|
||||
sudo install -Dm755 "$SRC_DIR/server/target/release/lesavka-uvc" /usr/local/bin/lesavka-uvc
|
||||
sudo install -Dm755 "$SRC_DIR/scripts/daemon/lesavka-core.sh" /usr/local/bin/lesavka-core.sh
|
||||
sudo install -Dm755 "$SRC_DIR/scripts/daemon/lesavka-uvc.sh" /usr/local/bin/lesavka-uvc.sh
|
||||
|
||||
echo "==> 6a. Systemd units - lesavka-core"
|
||||
cat <<'UNIT' | sudo tee /etc/systemd/system/lesavka-core.service >/dev/null
|
||||
@ -178,6 +179,7 @@ Environment=RUST_LOG=lesavka_server=info,lesavka_server::audio=info,lesavka_serv
|
||||
Environment=RUST_BACKTRACE=1
|
||||
Environment=GST_DEBUG="*:2,alsasink:6,alsasrc:6"
|
||||
Environment=LESAVKA_UVC_CODEC=mjpeg
|
||||
Environment=LESAVKA_UVC_EXTERNAL=1
|
||||
Restart=always
|
||||
RestartSec=5
|
||||
StandardError=append:/tmp/lesavka-server.stderr
|
||||
@ -194,6 +196,29 @@ sudo systemctl enable --now lesavka-core
|
||||
sudo systemctl restart lesavka-core
|
||||
echo "✅ lesavka-core installed and restarted..."
|
||||
|
||||
cat <<'UNIT' | sudo tee /etc/systemd/system/lesavka-uvc.service >/dev/null
|
||||
[Unit]
|
||||
Description=lesavka UVC control helper
|
||||
After=lesavka-core.service
|
||||
Requires=lesavka-core.service
|
||||
|
||||
[Service]
|
||||
ExecStart=/usr/local/bin/lesavka-uvc.sh
|
||||
Restart=always
|
||||
RestartSec=2
|
||||
KillSignal=SIGTERM
|
||||
TimeoutStopSec=10
|
||||
StandardError=append:/tmp/lesavka-uvc.stderr
|
||||
User=root
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
UNIT
|
||||
|
||||
sudo systemctl enable --now lesavka-uvc
|
||||
sudo systemctl restart lesavka-uvc
|
||||
echo "✅ lesavka-uvc installed and restarted..."
|
||||
|
||||
sudo systemctl enable --now lesavka-server
|
||||
sudo systemctl restart lesavka-server
|
||||
echo "✅ lesavka-server installed and restarted..."
|
||||
|
||||
@ -476,8 +476,12 @@ async fn main() -> anyhow::Result<()> {
|
||||
|
||||
let gadget = UsbGadget::new("lesavka");
|
||||
if std::env::var("LESAVKA_DISABLE_UVC").is_err() {
|
||||
let bin = uvc_ctrl_bin();
|
||||
tokio::spawn(supervise_uvc_control(bin));
|
||||
if std::env::var("LESAVKA_UVC_EXTERNAL").is_ok() {
|
||||
info!("📷 UVC control helper external; not spawning");
|
||||
} else {
|
||||
let bin = uvc_ctrl_bin();
|
||||
tokio::spawn(supervise_uvc_control(bin));
|
||||
}
|
||||
} else {
|
||||
info!("📷 UVC disabled (LESAVKA_DISABLE_UVC set)");
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user