diff options
author | doc <doc@filenotfound.org> | 2025-06-30 20:11:52 +0000 |
---|---|---|
committer | doc <doc@filenotfound.org> | 2025-06-30 20:11:52 +0000 |
commit | 41e897f4945aaf8fbcdf0b12ac2f08c5e6ae0458 (patch) | |
tree | db7c3520fd91abc3cf56b1a52095d23f3a80d059 /startemup.sh |
Diffstat (limited to 'startemup.sh')
-rwxr-xr-x | startemup.sh | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/startemup.sh b/startemup.sh new file mode 100755 index 0000000..d0f5f17 --- /dev/null +++ b/startemup.sh @@ -0,0 +1,67 @@ +#!/usr/bin/env bash +# Launches Python virtual environments in separate screen sessions or manages their status + +declare -A VENV_APPS=( + [archivecontrol]="recordit2.py" + [archivelist]="recordit2.py" + [recordtheshow]="app.py" + [radiotoot]="app.py" + [hostingtoot]="app.py" + [radiotoot]="live.py" +) + +SCRIPT_BASE="/home/doc/genesis-tools" +VENV_BASE="/home/doc" + +if [[ "$1" == "--check" ]]; then + echo "🔍 Checking screen session health..." + for name in "${!VENV_APPS[@]}"; do + if screen -list | grep -q "\.${name}[[:space:]]"; then + echo "📦 $name ✅ Running" + else + echo "📦 $name ❌ Not running" + fi + done + exit 0 +fi + +if [[ "$1" == "--stop" ]]; then + echo "🛑 Stopping all screen sessions..." + for name in "${!VENV_APPS[@]}"; do + if screen -list | grep -q "\.${name}[[:space:]]"; then + screen -S "$name" -X quit && echo "🛑 $name stopped" + else + echo "⚠️ $name not running" + fi + done + exit 0 +fi + +if [[ "$1" == "--restart" ]]; then + echo "🔄 Restarting all apps..." + "$0" --stop + sleep 2 + "$0" + exit 0 +fi + +for name in "${!VENV_APPS[@]}"; do + script_name="${VENV_APPS[$name]}" + script_path="$SCRIPT_BASE/$name/$script_name" + + # Use 'toot' venv for both radiotoot and hostingtoot + if [[ "$name" == "radiotoot" || "$name" == "hostingtoot" ]]; then + venv_activate="$VENV_BASE/toot/bin/activate" + else + venv_activate="$VENV_BASE/$name/bin/activate" + fi + + if [[ -f "$script_path" && -f "$venv_activate" ]]; then + echo "🚀 Launching $name in screen session..." + screen -S "$name" -dm bash -c "source '$venv_activate'; cd '$SCRIPT_BASE/$name'; python3 '$script_name'" + else + echo "⚠️ Script or venv not found for $name" + fi +done + +echo "✅ All venv apps launched in screen sessions." |