#!/bin/sh set +x # 1. Force all child processes (rtorrent, nginx) to use jemalloc export LD_PRELOAD="/usr/lib/aarch64-linux-gnu/libjemalloc.so.2" # 2. Tune allocator for low fragmentation and ARM big.LITTLE background cleanup export MALLOC_CONF="background_thread:true,dirty_decay_ms:3000,muzzy_decay_ms:3000" # Clean up old session files rm -f /var/lib/rtorrent/.session/rtorrent.lock rm -f /var/lib/rtorrent/.session/*.cache # Start rtorrent inside detached tmux session and signal "rtorrent" lock upon exit tmux new-session -d -s "rtorrent" -- "rtorrent -n -o import=/etc/rtorrent.rc; tmux wait-for -S rtorrent" # Start ttyd in background ttyd -s 15 -W tmux attach -t "rtorrent" & # Start xmlrpc to scgi proxy in background nginx -c /etc/nginx/nginx.conf & # Lightweight alternative: blocking wait specifically for the rtorrent tmux window tmux wait-for rtorrent