简体   繁体   English

Laravel 调度程序命令永远不会第二次运行

[英]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.然而,就在我们将服务器设置为与 Envoyer 一起运行之后,调度程序在第一次之后突然就不再执行了。

In other words, if the schedule is set to every minute in Forge, it runs once and then never appends the logs.换句话说,如果在 Forge 中将计划设置为每分钟,它会运行一次,然后从不附加日志。

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.我添加了 Envoyer 心跳来每 10 分钟跟踪一次,但它不会触发thenPing()方法来通知 Envoyer……即使在第一次运行之后。

I can delete the cron entry and recreate it, forcing it to run that one time.我可以删除 cron 条目并重新创建它,强制它运行一次。

All of these run fine if they are given their own cronjob.如果给它们自己的 cronjob,所有这些都运行良好。

When I check for any /storage/framework/schedule-* lock files, I find nothing to delete that could be blocking them.当我检查任何/storage/framework/schedule-*锁定文件时,我发现没有任何可以阻止它们删除的内容。

Nothing in the Laravel log files showing a problem. Laravel 日志文件中没有任何显示问题。

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通过将 cronjob 从php /home/forge/default/artisan schedule:run更改为php /home/forge/default/current/artisan schedule:run

This allowed the Laravel scheduler to run correctly.这允许 Laravel 调度程序正确运行。 However, the methods thenPing and pingBefore still never actually do their job.然而, thenPingpingBefore方法仍然没有真正完成它们的工作。

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.为什么内置的 ping 方法不起作用是个谜。 Would love to know why.很想知道为什么。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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