简体   繁体   中英

Laravel scheduler command never runs a 2nd time

I've configured scheduler to run once every minute to execute two commands:

$schedule->command('amazon:read-sqs')
    ->everyMinute()
    ->runInBackground()
    ->withoutOverlapping()
    ->sendOutputTo(storage_path('logs/cmd/amazon_read_sqs.log'), true)
    ->thenPing('http://beats.envoyer.io/heartbeat/SoMeRaNdOmHaSh1');

$schedule->command('jobs:dispatcher', ['--max' => 100])
    ->everyMinute()
    ->runInBackground()
    ->withoutOverlapping()
    ->sendOutputTo(storage_path('logs/cmd/jobs_dispatcher.log'), true)
    ->thenPing('http://beats.envoyer.io/heartbeat/SoMeRaNdOmHaSh2');

It's been running great for the past month of development. However, right after setting up our server to run with Envoyer, the scheduler suddenly never executes after the first time.

In other words, if the schedule is set to every minute in Forge, it runs once and then never appends the logs.

I added Envoyer heartbeats to track it every 10 min but it doesn't trigger the thenPing() method to notify Envoyer...even after that first run.

I can delete the cron entry and recreate it, forcing it to run that one time.

All of these run fine if they are given their own cronjob.

When I check for any /storage/framework/schedule-* lock files, I find nothing to delete that could be blocking them.

Nothing in the Laravel log files showing a problem.

Any ideas?

Solved this by changing the cronjob from php /home/forge/default/artisan schedule:run to php /home/forge/default/current/artisan schedule:run

This allowed the Laravel scheduler to run correctly. However, the methods thenPing and pingBefore still never actually do their job.

To fix that, I had to manually add this line after each command:

 (new Client())->get('http://beats.envoyer.io/heartbeat/SoMeRaNdOmHaSh');

Why the built-in ping methods don't work is a mystery. Would love to know why.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM