我创建了一个控制台命令(目前)仅输出一条日志语句。
该命令每分钟安排一次。
我有一个执行 Artisan::call() 的控制器端点(位于 /scheduler/run);到工匠时间表:运行命令。
在本地它工作得很好(laravel valet&nginx),但是在生产(apache)上,当到达该端点时没有任何反应...... 我确实从控制器收到了回复,但调度程序从未被触发。
我的路线:
Route::get('/scheduler/run', SchedulerController::class)->name('scheduler');
我的控制器:
<?php
namespace App\Http\Controllers;
use Illuminate\Support\Facades\Artisan;
class SchedulerController extends Controller
{
public function __invoke()
{
Artisan::call('schedule:run');
return response()->noContent();
}
}
我的内核.php
<?php
namespace App\Console;
use App\Console\Commands\PingCommand;
use App\Console\Commands\RefreshTwikeyKey;
use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
class Kernel extends ConsoleKernel
{
/**
* The Artisan commands provided by your application.
*
* @var array
*/
protected $commands = [
PingCommand::class,
];
/**
* Define the application's command schedule.
*
* @param \Illuminate\Console\Scheduling\Schedule $schedule
* @return void
*/
protected function schedule(Schedule $schedule)
{
$schedule->command(PingCommand::class)->everyMinute();
}
/**
* Register the commands for the application.
*
* @return void
*/
protected function commands()
{
$this->load(__DIR__.'/Commands');
require base_path('routes/console.php');
}
}
您解决过这个问题吗?面对完全相同的行为。