feat(recording): consolidate recording pipeline on server B
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
LISGLOSIPS_ENTRYPOINT=apps/worker-recording/dist/main.js
|
||||
LISGLOSIPS_SERVICE_NAME=worker-recording
|
||||
LISGLOSIPS_LOG_LEVEL=info
|
||||
DATABASE_URL=mysql://user:password@127.0.0.1:3306/lisglosips
|
||||
RECORDING_SOURCE_MODE=local
|
||||
RECORDING_LOCAL_READY_DIR=/dev/shm/voip_rec/ready
|
||||
RECORDING_LOCAL_ROOT=/data/recordings
|
||||
RECORDING_SCAN_INTERVAL_MS=10000
|
||||
RECORDING_MAX_FILES_PER_SCAN=50
|
||||
RECORDING_DELETE_SOURCE_AFTER_COPY=true
|
||||
@@ -0,0 +1,39 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
BASE_DIR=${1:-/dev/shm/voip_rec}
|
||||
INCOMING_DIR="$BASE_DIR/incoming"
|
||||
READY_DIR="$BASE_DIR/ready"
|
||||
FAILED_DIR="$BASE_DIR/failed"
|
||||
MIN_AGE_SECONDS=${MIN_AGE_SECONDS:-15}
|
||||
|
||||
mkdir -p "$INCOMING_DIR" "$READY_DIR" "$FAILED_DIR"
|
||||
chmod 0750 "$BASE_DIR" "$INCOMING_DIR" "$READY_DIR" "$FAILED_DIR"
|
||||
|
||||
find "$INCOMING_DIR" -type f \( -name '*.wav' -o -name '*.mp3' \) -print0 |
|
||||
while IFS= read -r -d '' source; do
|
||||
if [ ! -s "$source" ]; then
|
||||
continue
|
||||
fi
|
||||
now=$(date +%s)
|
||||
mtime=$(stat -c %Y "$source")
|
||||
if [ $((now - mtime)) -lt "$MIN_AGE_SECONDS" ]; then
|
||||
continue
|
||||
fi
|
||||
if command -v fuser >/dev/null 2>&1 && fuser -s -- "$source"; then
|
||||
continue
|
||||
fi
|
||||
rel=${source#"$INCOMING_DIR"/}
|
||||
part="$READY_DIR/$rel.part"
|
||||
ready="$READY_DIR/$rel.ready"
|
||||
failed="$FAILED_DIR/$rel"
|
||||
mkdir -p "$(dirname "$part")" "$(dirname "$failed")"
|
||||
chmod 0750 "$(dirname "$part")" "$(dirname "$failed")"
|
||||
if [ -e "$ready" ] || [ -e "$part" ]; then
|
||||
mv -- "$source" "$failed.$(date -u +%Y%m%dT%H%M%SZ).duplicate"
|
||||
continue
|
||||
fi
|
||||
mv -- "$source" "$part"
|
||||
chmod 0640 "$part"
|
||||
mv -- "$part" "$ready"
|
||||
done
|
||||
@@ -0,0 +1,5 @@
|
||||
[Service]
|
||||
User=lisglo-recorder
|
||||
Group=lisglosips
|
||||
SupplementaryGroups=rtpengine
|
||||
ReadWritePaths=/data/recordings /dev/shm/voip_rec/ready /run/lisglosips /run/lisglo-recorder
|
||||
@@ -0,0 +1,15 @@
|
||||
[Unit]
|
||||
Description=Finalize local RTPEngine recordings for LisgloSIPS
|
||||
After=rtpengine-recording-daemon.service
|
||||
Requires=rtpengine-recording-daemon.service
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
User=rtpengine
|
||||
Group=rtpengine
|
||||
ExecStart=/usr/local/sbin/lisglosips-recording-finalize /dev/shm/voip_rec
|
||||
NoNewPrivileges=true
|
||||
PrivateTmp=true
|
||||
ProtectSystem=strict
|
||||
ProtectHome=true
|
||||
ReadWritePaths=/dev/shm/voip_rec
|
||||
@@ -0,0 +1,12 @@
|
||||
[Unit]
|
||||
Description=Finalize local RTPEngine recordings every five seconds
|
||||
|
||||
[Timer]
|
||||
OnBootSec=10s
|
||||
OnUnitActiveSec=5s
|
||||
AccuracySec=1s
|
||||
Unit=lisglosips-recording-finalize.service
|
||||
Persistent=true
|
||||
|
||||
[Install]
|
||||
WantedBy=timers.target
|
||||
Reference in New Issue
Block a user