Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ansible/inventory/group_vars/all.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ sync_to_x_source_dir: /mnt/ssd/data
sync_to_x_destinations:
- /mnt/external/data
- /mnt/nas/data
sync_to_x_rsync_bw_limit: 100m
sync_to_x_rsync_bw_limit: 200m
sync_to_x_timer_interval: 1min

# Journald Configuration
Expand Down
1 change: 1 addition & 0 deletions ansible/roles/sync_to_x/defaults/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ sync_to_x_hostname: "{{ ansible_hostname }}"
sync_to_x_rsync_bw_limit: 100m
sync_to_x_timer_interval: 1min
sync_to_x_free_space_limit_gb: 10
sync_to_x_active_file_threshold_sec: 30

# System paths
sync_to_x_script_path: /opt/drs/service/sync_to_x/sync_to_x.sh
Expand Down
12 changes: 8 additions & 4 deletions ansible/roles/sync_to_x/templates/sync_to_x.sh.j2
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,14 @@ error_exit() {
# Find mcap files (excluding metadata.yaml) and sort by modification time (oldest first)
find "$SOURCE_DIR" -name "*.mcap" -type f -printf '%T@ %p\n' | sort -n | cut -d' ' -f2- | while read -r mcap_file; do

# Check if file is currently open by any process (e.g., recording is still active)
if fuser "$mcap_file" > /dev/null 2>&1; then
echo "Skipping active file (in use): $mcap_file"
continue
# Skip files modified within the threshold (i.e., recording is still active or
# just finished). Avoids fuser/lsof which cause excessive NFS stat() calls when
# SOURCE_DIR or DEST is on a NAS mount, leading to severe slowdowns.
file_mtime=$(stat -c %Y "$mcap_file" 2>/dev/null || echo 0)
now=$(date +%s)
if [ $((now - file_mtime)) -lt {{ sync_to_x_active_file_threshold_sec }} ]; then
echo "Skipping recently modified file (active within {{ sync_to_x_active_file_threshold_sec }}s): $mcap_file"
continue
fi

# Get relative path (to preserve directory structure)
Expand Down
Loading