add source code and readme

This commit is contained in:
2025-12-24 14:35:17 +01:00
parent 7c92e1e610
commit 74324d5a1b
331 changed files with 39272 additions and 1 deletions

View File

@@ -0,0 +1,28 @@
FROM pixelfed-base AS pixelfed-worker
# Install supervisor for worker management
RUN apk add --no-cache supervisor
# Worker-specific PHP configuration for background processing
RUN echo "memory_limit = 512M" >> /usr/local/etc/php/conf.d/worker.ini \
&& echo "max_execution_time = 300" >> /usr/local/etc/php/conf.d/worker.ini \
&& echo "max_input_time = 300" >> /usr/local/etc/php/conf.d/worker.ini \
&& echo "pcntl.enabled = 1" >> /usr/local/etc/php/conf.d/worker.ini
# Copy worker-specific configuration files
COPY supervisord-worker.conf /etc/supervisor/conf.d/supervisord.conf
COPY entrypoint-worker.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
# Create supervisor directories
RUN mkdir -p /var/log/supervisor
# Health check for worker container (check horizon status)
HEALTHCHECK --interval=60s --timeout=10s --start-period=60s --retries=3 \
CMD su-exec pixelfed php /var/www/pixelfed/artisan horizon:status || exit 1
# Run as root to manage processes
USER root
ENTRYPOINT ["/entrypoint.sh"]
CMD ["supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"]

View File

@@ -0,0 +1,58 @@
#!/bin/sh
set -e
# Source common functions
. /usr/local/bin/entrypoint-common.sh
echo "Starting Pixelfed Worker Container..."
# CRITICAL FIX: Remove stale package discovery cache files FIRST
echo "Removing stale package discovery cache files..."
rm -f /var/www/pixelfed/bootstrap/cache/packages.php || true
rm -f /var/www/pixelfed/bootstrap/cache/services.php || true
rm -f /var/www/pixelfed/bootstrap/cache/config.php || true
# Create worker-specific directories
mkdir -p /var/log/supervisor
# Skip database initialization - handled by init-job
# Just set up basic directory structure
echo "Setting up worker container..."
setup_directories
# Wait for database to be ready (but don't initialize)
echo "Waiting for database connection..."
cd /var/www/pixelfed
for i in $(seq 1 12); do
if php artisan migrate:status >/dev/null 2>&1; then
echo "Database is ready!"
break
fi
echo "Database not ready yet, waiting... (attempt $i/12)"
sleep 5
done
# Clear Laravel caches to ensure fresh service provider registration
echo "Clearing Laravel caches and regenerating package discovery..."
php artisan config:clear || true
php artisan route:clear || true
php artisan view:clear || true
php artisan cache:clear || true
# Remove and regenerate package discovery cache
rm -f bootstrap/cache/packages.php bootstrap/cache/services.php || true
php artisan package:discover --ansi || true
# Clear and restart Horizon queues
echo "Preparing Horizon queue system..."
# Clear any existing queue data
php artisan horizon:clear || true
# Publish Horizon assets if needed
php artisan horizon:publish || true
echo "Worker container initialization complete!"
echo "Starting Laravel Horizon and Scheduler..."
# Execute the main command (supervisord)
exec "$@"

View File

@@ -0,0 +1,67 @@
[supervisord]
nodaemon=true
logfile=/dev/stdout
logfile_maxbytes=0
pidfile=/tmp/supervisord.pid
[unix_http_server]
file=/tmp/supervisor.sock
chmod=0700
[supervisorctl]
serverurl=unix:///tmp/supervisor.sock
[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface
[program:horizon]
command=php /var/www/pixelfed/artisan horizon
directory=/var/www/pixelfed
user=pixelfed
autostart=true
autorestart=true
startretries=5
numprocs=1
startsecs=0
process_name=%(program_name)s_%(process_num)02d
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
priority=100
# Kill horizon gracefully on stop
stopsignal=TERM
stopwaitsecs=60
[program:schedule]
command=php /var/www/pixelfed/artisan schedule:work
directory=/var/www/pixelfed
user=pixelfed
autostart=true
autorestart=true
startretries=5
numprocs=1
startsecs=0
process_name=%(program_name)s_%(process_num)02d
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
priority=200
# Additional worker for high-priority queues (including media)
[program:high-priority-worker]
command=php /var/www/pixelfed/artisan queue:work --queue=high,mmo,default --sleep=1 --tries=3 --max-time=1800
directory=/var/www/pixelfed
user=pixelfed
autostart=true
autorestart=true
startretries=5
numprocs=1
startsecs=0
process_name=%(program_name)s_%(process_num)02d
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
priority=300