我做了一年的already..Before开发者,我在Windows上使用了laravel,但是自从我使用linux之后,我在laravel..every上遇到了一个大问题,我在linux上启动了一个作业,我的机器崩溃了。但在窗户上一切正常。
//我的财务主任
<?php
namespace App\Http\Controllers;
use App\Jobs\CustomerJob;
use Illuminate\Http\Request;
class SendEmailControllers extends Controller
{
public function sendEmail(){
dispatch(new CustomerJob())->delay(now()->addMinutes(1));
dd('Email has been delivered');
}}
//职务守则
<?php
namespace App\Jobs;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldBeUnique;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Facades\Mail;
use App\Mail\WelcomeUserMail;
class CustomerJob implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
/**
* Create a new job instance.
*
* @return void
*/
public function __construct()
{
//
}
/**
* Execute the job.
*
* @return void
*/
public function handle()
{
Mail::to('bramslevel129@gmail.com')->send(new WelcomeUserMail);
}}
以下是重新启动机器时显示的错误。错误显示在我的Failed_job表上。
//错误
Illuminate\Queue\MaxAttemptsExceededException:
App\Jobs\CustomerJob has been attempted too many times or run too long.
The job may have previously timed out.
in /home/dev/www/laravel-authentication/vendor/laravel/framework/src/Illuminate/Queue/Worker.php:750 Stack trace:#0 /home/dev/www/laravel-authentication/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(504): Illuminate\Queue\Worker->maxAttemptsExceededException()
#1 /home/dev/www/laravel-authentication/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(418): Illuminate\Queue\Worker->markJobAsFailedIfAlreadyExceedsMaxAttempts()
#2 /home/dev/www/laravel-authentication/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(378): Illuminate\Queue\Worker->process()
#3 /home/dev/www/laravel-authentication/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(172): Illuminate\Queue\Worker->runJob()
#4 /home/dev/www/laravel-authentication/vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php(126): Illuminate\Queue\Worker->daemon()
#5 /home/dev/www/laravel-authentication/vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php(110): Illuminate\Queue\Console\WorkCommand->runWorker()
#6 /home/dev/www/laravel-authentication/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(36): Illuminate\Queue\Console\WorkCommand->handle()
#7 /home/dev/www/laravel-authentication/vendor/laravel/framework/src/Illuminate/Container/Util.php(41): Illuminate\Container\BoundMethod::Illuminate\Container\{closure}()
#8 /home/dev/www/laravel-authentication/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(93): Illuminate\Container\Util::unwrapIfClosure()
#9 /home/dev/www/laravel-authentication/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(37): Illuminate\Container\BoundMethod::callBoundMethod()
#10 /home/dev/www/laravel-authentication/vendor/laravel/framework/src/Illuminate/Container/Container.php(653): Illuminate\Container\BoundMethod::call()
#11 /home/dev/www/laravel-authentication/vendor/laravel/framework/src/Illuminate/Console/Command.php(136): Illuminate\Container\Container->call()
#12 /home/dev/www/laravel-authentication/vendor/symfony/console/Command/Command.php(291): Illuminate\Console\Command->execute()
#13 /home/dev/www/laravel-authentication/vendor/laravel/framework/src/Illuminate/Console/Command.php(121): Symfony\Component\Console\Command\Command->run()
#14 /home/dev/www/laravel-authentication/vendor/symfony/console/Application.php(989): Illuminate\Console\Command->run()
#15 /home/dev/www/laravel-authentication/vendor/symfony/console/Application.php(299): Symfony\Component\Console\Application->doRunCommand()
#16 /home/dev/www/laravel-authentication/vendor/symfony/console/Application.php(171): Symfony\Component\Console\Application->doRun()
#17 /home/dev/www/laravel-authentication/vendor/laravel/framework/src/Illuminate/Console/Application.php(102): Symfony\Component\Console\Application->run()
#18 /home/dev/www/laravel-authentication/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(129): Illuminate\Console\Application->run()
#19 /home/dev/www/laravel-authentication/artisan(37): Illuminate\Foundation\Console\Kernel->handle()
#20 {main}发布于 2022-05-24 13:25:54
尝试设定破坏规则查找作业以停止挂起您的系统
//CustomerJob.php
/**
* The number of seconds the job can run before timing out.
*
* @var int
*/
public $timeout = 15; // just for your case
/**
* Indicate if the job should be marked as failed on timeout.
*
* @var bool
*/
public $failOnTimeout = true;
/**
* The number of times the job may be attempted.
*
* @var int
*/
public $tries = 3;
/**
* The maximum number of unhandled exceptions to allow before failing.
*
* @var int
*/
public $maxExceptions = 1;
/**
* Execute the job.
*
* @return void
*/
public function handle()
{
Log::debug('jobs', ['job start']);
Mail::to('bramslevel129@gmail.com')->send(new WelcomeUserMail);
Log::debug('jobs', ['job end']);
}并检查project_folder/storage/logs/laravel.log (如果日志配置为单个文件)或与日志配置相对应--可能存在与作业本身无关的错误(例如,由于邮件配置错误而无法发送邮件)。
步骤2:尝试将邮件驱动程序设置为日志以查看更改并再次检查日志
# .env file
# you can comment lines using # in this file
# MAIL_MAILER=smtp
MAIL_MAILER=log
MAIL_LOG_CHANNEL=debughttps://stackoverflow.com/questions/72351521
复制相似问题