feat: Add container restart functionality from web UI
- Added restart button to settings page - Created /api/restart endpoint (file-flag based) - Implemented watch-restart.sh daemon - Added systemd service for restart watcher - Updated README with restart setup instructions - Container automatically restarts when settings changed Settings flow: 1. User edits settings in web UI 2. Click 'Save Settings' to persist to .env 3. Click 'Restart Bot' to apply changes 4. Watcher detects flag and restarts container 5. New settings loaded automatically
This commit is contained in:
40
watch-restart.sh
Executable file
40
watch-restart.sh
Executable file
@@ -0,0 +1,40 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Container Restart Watcher
|
||||
# Monitors for restart flag and restarts the trading-bot container
|
||||
#
|
||||
|
||||
WATCH_DIR="/home/icke/traderv4/logs"
|
||||
RESTART_FLAG="$WATCH_DIR/.restart-requested"
|
||||
CONTAINER_NAME="trading-bot-v4"
|
||||
|
||||
echo "🔍 Watching for restart requests in: $WATCH_DIR"
|
||||
echo "📦 Container: $CONTAINER_NAME"
|
||||
echo ""
|
||||
|
||||
# Create logs directory if it doesn't exist
|
||||
mkdir -p "$WATCH_DIR"
|
||||
|
||||
while true; do
|
||||
if [ -f "$RESTART_FLAG" ]; then
|
||||
echo "🔄 Restart requested at $(cat $RESTART_FLAG)"
|
||||
echo "🔄 Restarting container: $CONTAINER_NAME"
|
||||
|
||||
# Remove flag before restart
|
||||
rm "$RESTART_FLAG"
|
||||
|
||||
# Restart container
|
||||
cd /home/icke/traderv4
|
||||
docker compose restart $CONTAINER_NAME
|
||||
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "✅ Container restarted successfully"
|
||||
else
|
||||
echo "❌ Failed to restart container"
|
||||
fi
|
||||
echo ""
|
||||
fi
|
||||
|
||||
# Check every 2 seconds
|
||||
sleep 2
|
||||
done
|
||||
Reference in New Issue
Block a user