#!/bin/bash

echo "🔧 Fixing worker permissions..."

# Create directories if they don't exist
#mkdir -p ./storage/logs
#mkdir -p ./storage/cache
#mkdir -p ./src/Framework/CommandBus/storage/queue

# Host-System Permissions korrigieren
echo "📁 Fixing host permissions..."
chmod -R 775 ../storage/ 2>/dev/null || true
chmod -R 775 ../src/Framework/CommandBus/storage/ 2>/dev/null || true

echo "✅ Host permissions fixed"

echo "🐳 Restarting worker container..."
docker-compose restart queue-worker

echo "⏱️  Waiting for worker to start..."
sleep 3

echo "📋 Worker logs:"
docker-compose logs --tail=20 queue-worker

echo "✅ Worker restarted successfully!"
