Skip to content

Commit

Permalink
fix: Replace systemd with supervisor for managing messenger worker se…
Browse files Browse the repository at this point in the history
…rvice
  • Loading branch information
MrAnyx committed Jan 3, 2025
1 parent 978819a commit 4acb2e4
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 16 deletions.
6 changes: 2 additions & 4 deletions .docker/entrypoint.prod.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@ set -e
echo "Running database migrations..."
php bin/console doctrine:migrations:migrate --no-interaction --allow-no-migration

# Enable and start the worker
systemctl --user daemon-reload
systemctl --user enable messenger-worker
systemctl --user start messenger-worker
# Update and start supervisor service
echo "Starting supervisor..."

# Start Apache server
echo "Starting Apache..."
Expand Down
17 changes: 17 additions & 0 deletions .docker/messenger-worker.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[supervisord]
nodaemon=true
logfile=/dev/null
logfile_maxbytes=0

[program:messenger-consume]
command=php /var/www/html/bin/console messenger:consume async --time-limit=3600
user=root
numprocs=2
startsecs=0
autostart=true
autorestart=true
startretries=10
process_name=%(program_name)s_%(process_num)02d
stdout_logfile=/dev/fd/1
stdout_logfile_maxbytes=0
redirect_stderr=true
10 changes: 0 additions & 10 deletions .docker/messenger-worker.service

This file was deleted.

4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
FROM php:8.3.15-apache AS base
RUN apt-get update && apt-get install -y systemd
RUN apt-get update && apt-get install -y supervisor
WORKDIR /var/www/html
ADD --chmod=0755 https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/
RUN install-php-extensions intl
Expand All @@ -24,7 +24,7 @@ ENV APP_ENV=prod
ENV APP_DEBUG=0
RUN cp $PHP_INI_DIR/php.ini-production $PHP_INI_DIR/php.ini
COPY . .
COPY ./.docker/messenger-worker@.service /etc/systemd/user
COPY ./.docker/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
ADD --chmod=0755 ./.docker/entrypoint.prod.sh /usr/local/bin/entrypoint.sh
RUN composer install --no-dev --optimize-autoloader --no-interaction
RUN php bin/console cache:clear && php bin/console cache:warmup
Expand Down

0 comments on commit 4acb2e4

Please sign in to comment.