- Changed docker compose restart to use 'trading-bot' service name - Fixed 'no such service' error - Tested and verified restart functionality works
41 lines
923 B
Bash
Executable File
41 lines
923 B
Bash
Executable File
#!/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"
|
|
SERVICE_NAME="trading-bot"
|
|
|
|
echo "🔍 Watching for restart requests in: $WATCH_DIR"
|
|
echo "📦 Service: $SERVICE_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 service: $SERVICE_NAME"
|
|
|
|
# Remove flag before restart
|
|
rm "$RESTART_FLAG"
|
|
|
|
# Restart service using docker compose
|
|
cd /home/icke/traderv4
|
|
docker compose restart $SERVICE_NAME
|
|
|
|
if [ $? -eq 0 ]; then
|
|
echo "✅ Service restarted successfully"
|
|
else
|
|
echo "❌ Failed to restart service"
|
|
fi
|
|
echo ""
|
|
fi
|
|
|
|
# Check every 2 seconds
|
|
sleep 2
|
|
done
|