Stu Mason
Stu Mason

Activity

Issue Opened

Issue #60 opened: Scheduler supervisor uses schedule:run loop instead of schedule:work

Description

When the SchedulerDetector detects scheduled tasks, the DockerGenerator::getDockerSupervisorProgram() generates a supervisor config using an old-style schedule:run loop:

command=/bin/sh -c "while true; do /usr/local/bin/php /var/www/html/artisan schedule:run --verbose --no-interaction; sleep 60; done"

However, since Laravel 8.0, the schedule:work command is the preferred approach as it handles the loop internally and is more efficient.

The detector's own getSupervisorConfig() method correctly uses schedule:work:

command=php /app/artisan schedule:work

But getDockerSupervisorProgram() ignores this and uses its own implementation.

Suggested Fix

Update getDockerSupervisorProgram() to use schedule:work:

if (str_contains($name, 'scheduler')) {
    return <<<'CONF'
; ===================
; Laravel Scheduler
; ===================
[program:scheduler]
command=/usr/local/bin/php /var/www/html/artisan schedule:work
user=www-data
autostart=true
autorestart=true
priority=20
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0
CONF;
}

Additional Note

When users add scheduled tasks to routes/console.php AFTER running coolify:install, the Docker files are not regenerated. Users need to either:

  1. Run coolify:install --force to regenerate
  2. Manually add the scheduler to docker/supervisord.conf

Consider adding a warning or documentation about this, or perhaps a coolify:docker command that only regenerates Docker files.

Affected Files

  • src/Docker/DockerGenerator.php - getDockerSupervisorProgram() method (lines 891-906)