Compare commits

...

4 Commits

Author SHA1 Message Date
Brock H Caldwell
b86028acee wip: uses supervisord for worker and scheduler 2025-11-02 21:29:48 -06:00
Brock H Caldwell
b67781fe23 fix: adds created/updated at to event log 2025-11-02 16:16:19 -06:00
Brock H Caldwell
6920b82684 fix(migration): tries to set default value of null for created_at 2025-11-02 13:17:48 -06:00
Brock H Caldwell
0f291aa147 fix(migrations): migrations complains about sessions table not existing 2025-11-02 09:58:57 -06:00
8 changed files with 142 additions and 30 deletions

View File

@@ -33,11 +33,12 @@ services:
worker:
build:
dockerfile: docker/Dockerfile.base.worker
context: .
args:
FRANKENPHP_TAG: php8.4-alpine
# build:
# dockerfile: docker/Dockerfile.base.worker
# context: .
# args:
# FRANKENPHP_TAG: php8.4-alpine
image: torsearch-alpine
restart: unless-stopped
volumes:
- $PWD:/app
@@ -45,7 +46,7 @@ services:
tty: true
environment:
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:
@@ -96,6 +97,8 @@ services:
image: adminer
ports:
- "8081:8080"
environment:
ADMINER_DEFAULT_SERVER: database
volumes:

View File

@@ -15,6 +15,26 @@ framework:
max_retries: 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:
dsn: '%env(MESSENGER_TRANSPORT_DSN)%'
options:
@@ -36,7 +56,7 @@ framework:
routing:
# Route your messages to the transports
# 'App\Message\YourMessage': async
'App\Download\Action\Command\DownloadMediaCommand': async
'App\Download\Action\Command\DownloadMediaCommand': download
'App\Download\Action\Command\DownloadSeasonCommand': async
'App\Monitor\Action\Command\MonitorTvEpisodeCommand': async
'App\Monitor\Action\Command\MonitorTvSeasonCommand': async

View File

@@ -29,16 +29,16 @@ services:
depends_on:
- app
scheduler:
image: registry.caldwell.digital/home/torsearch-scheduler:${TAG}
volumes:
- /mnt/media/downloads/movies:/var/download/movies
- /mnt/media/downloads/tvshows:/var/download/tvshows
restart: always
command: -vv
depends_on:
- app
#
# scheduler:
# image: registry.caldwell.digital/home/torsearch-scheduler:${TAG}
# volumes:
# - /mnt/media/downloads/movies:/var/download/movies
# - /mnt/media/downloads/tvshows:/var/download/tvshows
# restart: always
# command: -vv
# depends_on:
# - app
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"
ENV APP_VERSION="${APP_VERSION}"
FROM code.caldwell.digital/home/torsearch-app:${APP_VERSION} AS base_image
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

View File

@@ -21,10 +21,7 @@ final class Version20250831013403 extends AbstractMigration
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql(<<<'SQL'
DROP TABLE sessions
SQL);
$this->addSql(<<<'SQL'
ALTER TABLE download CHANGE created_at created_at DATETIME NOT NULL, CHANGE updated_at updated_at DATETIME NOT NULL
DROP TABLE IF EXISTS sessions
SQL);
$this->addSql(<<<'SQL'
ALTER TABLE user_preference CHANGE preference_value preference_value VARCHAR(1024) DEFAULT NULL
@@ -37,9 +34,6 @@ final class Version20250831013403 extends AbstractMigration
$this->addSql(<<<'SQL'
CREATE TABLE sessions (sess_id VARBINARY(128) NOT NULL, sess_data LONGBLOB NOT NULL, sess_lifetime INT UNSIGNED NOT NULL, sess_time INT UNSIGNED NOT NULL, INDEX sess_lifetime_idx (sess_lifetime), PRIMARY KEY(sess_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_bin` ENGINE = InnoDB COMMENT = ''
SQL);
$this->addSql(<<<'SQL'
ALTER TABLE download CHANGE created_at created_at DATETIME DEFAULT NULL, CHANGE updated_at updated_at DATETIME DEFAULT NULL
SQL);
$this->addSql(<<<'SQL'
ALTER TABLE user_preference CHANGE preference_value preference_value VARCHAR(255) DEFAULT NULL
SQL);

View File

@@ -0,0 +1,35 @@
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20251102221034 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql(<<<'SQL'
ALTER TABLE event_log ADD created_at DATETIME NULL, ADD updated_at DATETIME NULL
SQL);
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql(<<<'SQL'
ALTER TABLE event_log DROP created_at, DROP updated_at
SQL);
}
}

View File

@@ -6,10 +6,13 @@ use App\EventLog\Framework\Repository\EventLogRepository;
use App\User\Framework\Entity\User;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Timestampable\Traits\TimestampableEntity;
#[ORM\Entity(repositoryClass: EventLogRepository::class)]
class EventLog
{
use TimestampableEntity;
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(nullable: true)]