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.
This commit is contained in:
@@ -43,6 +43,13 @@ done
|
|||||||
|
|
||||||
>&2 echo "Target database \"$target_db\" is ready."
|
>&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)
|
# Run migrations (use safe runner in production)
|
||||||
echo "Running database migrations..."
|
echo "Running database migrations..."
|
||||||
if [ "$NODE_ENV" = "production" ]; then
|
if [ "$NODE_ENV" = "production" ]; then
|
||||||
|
|||||||
@@ -823,8 +823,8 @@ EOF
|
|||||||
|
|
||||||
create_systemd_services() {
|
create_systemd_services() {
|
||||||
log_step "Creating 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 <<EOF
|
cat > /etc/systemd/system/picpeak-backend.service <<EOF
|
||||||
[Unit]
|
[Unit]
|
||||||
Description=PicPeak Backend Service
|
Description=PicPeak Backend Service
|
||||||
@@ -844,27 +844,10 @@ StandardError=append:$NATIVE_APP_DIR/logs/backend-error.log
|
|||||||
[Install]
|
[Install]
|
||||||
WantedBy=multi-user.target
|
WantedBy=multi-user.target
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
# Workers service
|
|
||||||
cat > /etc/systemd/system/picpeak-workers.service <<EOF
|
|
||||||
[Unit]
|
|
||||||
Description=PicPeak Background Workers
|
|
||||||
After=network.target picpeak-backend.service
|
|
||||||
|
|
||||||
[Service]
|
# Note: Workers (fileWatcher, expirationChecker, emailProcessor) are now started
|
||||||
Type=simple
|
# automatically by server.js, so a separate workers service is no longer needed.
|
||||||
User=$NATIVE_APP_USER
|
# Legacy picpeak-workers.service will be cleaned up during installation.
|
||||||
WorkingDirectory=$NATIVE_APP_DIR/app/backend
|
|
||||||
Environment="NODE_ENV=production"
|
|
||||||
ExecStart=/usr/bin/node src/services/workerManager.js
|
|
||||||
Restart=always
|
|
||||||
RestartSec=10
|
|
||||||
StandardOutput=append:$NATIVE_APP_DIR/logs/workers.log
|
|
||||||
StandardError=append:$NATIVE_APP_DIR/logs/workers-error.log
|
|
||||||
|
|
||||||
[Install]
|
|
||||||
WantedBy=multi-user.target
|
|
||||||
EOF
|
|
||||||
}
|
}
|
||||||
|
|
||||||
setup_caddy() {
|
setup_caddy() {
|
||||||
|
|||||||
Reference in New Issue
Block a user