The logs for the cron instance shows Preparing to run: /entrypoint cron -f as root and then nothing happens. No jobs are ever scheduled. I know @fideloper-fly has worked on some issues with this. Any ideas?
“No jobs are ever scheduled” implied that your cron tasks are creating queue jobs - is that right?
You can use fly ssh console -s and select an instance to SSH into it. They aren’t necessarily named obviously but in my experience, the 2nd will be cron, and the third instance will be worker.
You can run commands like ps aux | grep cron to see that CRON is a running process or ps aux | grep artisan to see if the queue worker is running.
Then perhaps head to /var/www/html and run php artisan schedule:run manually to see if it works.
Also be sure to check fly logs to see if there’s any error output.
Do you have env var setup for your queue connection? The default is sync, so they wouldn’t actually get run in a queue but whenever a job is dispatched (during the schedule:run command, if my guess is correct about the scheduled jobs firing jobs into the queue).
Be sure to check out the cron/queue docs to see if you missed anything, such as adjusting the php artisan queue:work command to work on the queue connection you need it to run on: Cron and Queues · Fly Docs
The evidence is that there are no jobs being scheduled.
My queue instance logs sit at INFO Processing jobs from the [default] queue. unless I manually use fly ssh console -s to SSH into the cron instance, go to /var/www/html and run php artisan schedule:run manually. Then jobs get scheduled and processed, as shown by the queue instance’s logs.
My env var is set properly to database which is what I use for my jobs.
I read over the “Cron and Queues” Fly Docs but I don’t see anything that I missed.
Interestingly though, there is nothing being added to the jobs table in the database and nothing is being logged by the worker, meaning jobs aren’t being dispatched to the right place. Note that this all works fine locally.
Running php artisan tinker and then running env("QUEUE_CONNECTION") returns "database", which is correct. It seems the cron instance is missing something…
I SSH’d into the cron instance with fly ssh console -s, went to the app directory, and ran artisan config:cache. And a minute later my jobs started being scheduled and ran!
For some reason, this was clearly not being run when the VM booted. I’m not sure if the issue was with the Dockerfile or the entrypoint.sh script in the docker directory.
I created a new Laravel Fly app to see what was different, following the tutorial Fly.io Docs: Run a Laravel App and noticed the docker directory has been changed to .fly, and the scripts have been changed.
Long story short, I replaced my Dockerfile and docker directory with the Dockerfile and .fly directory from the tutorial and… everything started working!