wip: uses supervisord for worker and scheduler

This commit is contained in:
Brock H Caldwell
2025-11-02 21:29:48 -06:00
parent b67781fe23
commit b86028acee
5 changed files with 103 additions and 23 deletions

View File

@@ -33,11 +33,12 @@ services:
worker: worker:
build: # build:
dockerfile: docker/Dockerfile.base.worker # dockerfile: docker/Dockerfile.base.worker
context: . # context: .
args: # args:
FRANKENPHP_TAG: php8.4-alpine # FRANKENPHP_TAG: php8.4-alpine
image: torsearch-alpine
restart: unless-stopped restart: unless-stopped
volumes: volumes:
- $PWD:/app - $PWD:/app
@@ -45,7 +46,7 @@ services:
tty: true tty: true
environment: environment:
TZ: America/Chicago TZ: America/Chicago
command: php /app/bin/console messenger:consume async --time-limit=3600 -vv # command: php /app/bin/console messenger:consume async --time-limit=3600 -vv
scheduler: scheduler:
@@ -96,6 +97,8 @@ services:
image: adminer image: adminer
ports: ports:
- "8081:8080" - "8081:8080"
environment:
ADMINER_DEFAULT_SERVER: database
volumes: volumes:

View File

@@ -15,6 +15,26 @@ framework:
max_retries: 1 max_retries: 1
multiplier: 1 multiplier: 1
download:
dsn: '%env(MESSENGER_TRANSPORT_DSN)%'
options:
use_notify: true
check_delayed_interval: 60000
queue_name: download
retry_strategy:
max_retries: 1
multiplier: 1
monitor:
dsn: '%env(MESSENGER_TRANSPORT_DSN)%'
options:
use_notify: true
check_delayed_interval: 60000
queue_name: monitor
retry_strategy:
max_retries: 1
multiplier: 1
media_cache: media_cache:
dsn: '%env(MESSENGER_TRANSPORT_DSN)%' dsn: '%env(MESSENGER_TRANSPORT_DSN)%'
options: options:
@@ -36,7 +56,7 @@ framework:
routing: routing:
# Route your messages to the transports # Route your messages to the transports
# 'App\Message\YourMessage': async # 'App\Message\YourMessage': async
'App\Download\Action\Command\DownloadMediaCommand': async 'App\Download\Action\Command\DownloadMediaCommand': download
'App\Download\Action\Command\DownloadSeasonCommand': async 'App\Download\Action\Command\DownloadSeasonCommand': async
'App\Monitor\Action\Command\MonitorTvEpisodeCommand': async 'App\Monitor\Action\Command\MonitorTvEpisodeCommand': async
'App\Monitor\Action\Command\MonitorTvSeasonCommand': async 'App\Monitor\Action\Command\MonitorTvSeasonCommand': async

View File

@@ -29,16 +29,16 @@ services:
depends_on: depends_on:
- app - app
#
scheduler: # scheduler:
image: registry.caldwell.digital/home/torsearch-scheduler:${TAG} # image: registry.caldwell.digital/home/torsearch-scheduler:${TAG}
volumes: # volumes:
- /mnt/media/downloads/movies:/var/download/movies # - /mnt/media/downloads/movies:/var/download/movies
- /mnt/media/downloads/tvshows:/var/download/tvshows # - /mnt/media/downloads/tvshows:/var/download/tvshows
restart: always # restart: always
command: -vv # command: -vv
depends_on: # depends_on:
- app # - app
redis: redis:

View File

@@ -1,10 +1,40 @@
FROM code.caldwell.digital/home/torsearch-base-worker:php8.4-alpine ###
# This version of Torsearch runs the scheduler, downloader, and worker
# in this one container. Each process is managerd by supervisord
# and can be configured via environment variables and more
# than one of these containers cans till be run.
###
ARG APP_VERSION="latest"
ARG APP_VERSION="0.0.0-dev" FROM code.caldwell.digital/home/torsearch-app:${APP_VERSION} AS base_image
ENV APP_VERSION="${APP_VERSION}"
COPY . /app
ENTRYPOINT [ "php", "/app/bin/console", "messenger:consume", "async" ] FROM alpine:3.22 AS build_stage
HEALTHCHECK --interval=3s --timeout=3s --retries=10 CMD return 0 COPY --from=base_image --chown=1000:1000 /app /app
RUN apk add --no-cache \
curl \
nginx \
php84 \
php84-ctype \
php84-curl \
php84-dom \
php84-fileinfo \
php84-fpm \
php84-gd \
php84-mbstring \
php84-mysqli \
php84-opcache \
php84-openssl \
php84-pdo_mysql \
php84-tokenizer \
supervisor
RUN ln -s /usr/bin/php84 /usr/bin/php
COPY docker/worker/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
# We start supervisord and supervisord starts
# respective service in the configuration file.
CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"]

View File

@@ -0,0 +1,27 @@
[supervisord]
nodaemon=true
logfile=/dev/null
logfile_maxbytes=0
pidfile=/run/supervisord.pid
[program:torsearch-worker]
command=/app/bin/console messenger:consume download -vv --time-limit 3600
numprocs=1
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0
autorestart=true
startretries=3
process_name=%(program_name)s_%(process_num)02d
[program:torsearch-scheduler]
command=/app/bin/console messenger:consume monitor -vv
numprocs=1
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0
autorestart=true
startretries=3
process_name=%(program_name)s_%(process_num)02d