From a59a4232ff5f7c40e300f2b7dab7f47d78cb5074 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 27 Nov 2025 16:13:50 +0000 Subject: [PATCH] Fix worker service and Docker storage permission issues (Issues #66, #67) Issue #66: Remove redundant picpeak-workers.service creation from setup script. Workers (fileWatcher, expirationChecker, emailProcessor) are now started automatically by server.js, so a separate systemd service is not needed. The legacy service cleanup code is retained for migration purposes. Issue #67: Ensure storage directories exist at container startup in wait-for-db.sh. When host directories are bind-mounted in Docker, the container's built-in directories are overridden. This fix creates the required directory structure (events/active, events/archived, thumbnails) before the application starts, preventing EACCES permission errors. --- backend/wait-for-db.sh | 7 +++++++ scripts/picpeak-setup.sh | 27 +++++---------------------- 2 files changed, 12 insertions(+), 22 deletions(-) diff --git a/backend/wait-for-db.sh b/backend/wait-for-db.sh index 24be434..802fb3a 100755 --- a/backend/wait-for-db.sh +++ b/backend/wait-for-db.sh @@ -43,6 +43,13 @@ done >&2 echo "Target database \"$target_db\" is ready." +# Ensure storage directories exist with proper permissions (Issue #67 fix) +# When host directories are bind-mounted, the container's built-in directories are overridden +# This ensures the required directory structure exists before the application starts +echo "Ensuring storage directories exist..." +STORAGE_BASE="${STORAGE_PATH:-/app/storage}" +mkdir -p "$STORAGE_BASE/events/active" "$STORAGE_BASE/events/archived" "$STORAGE_BASE/thumbnails" 2>/dev/null || true + # Run migrations (use safe runner in production) echo "Running database migrations..." if [ "$NODE_ENV" = "production" ]; then diff --git a/scripts/picpeak-setup.sh b/scripts/picpeak-setup.sh index f85a8d1..554f00f 100755 --- a/scripts/picpeak-setup.sh +++ b/scripts/picpeak-setup.sh @@ -823,8 +823,8 @@ EOF create_systemd_services() { log_step "Creating systemd services..." - - # Backend service + + # Backend service (includes workers - fileWatcher, expirationChecker are started by server.js) cat > /etc/systemd/system/picpeak-backend.service < /etc/systemd/system/picpeak-workers.service <