问题
My error log is getting filled with this useless text, I have set my job to only try once and the time out to 0 because the jobs can be really long and it depends on the user.
So the job has tries set at 1 timeout at 0, on laravel forge I have set my worker to have max tries at 1 and timeout 0, and still it gives me this error in the logs:
Illuminate\Queue\MaxAttemptsExceededException: A queued job has been attempted too many times. The job may have previously timed out. in /home/forge/Altpocket.io/vendor/laravel/framework/src/Illuminate/Queue/Worker.php:385
Stack trace:
#0 /home/forge/Altpocket.io/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(311): Illuminate\Queue\Worker->markJobAsFailedIfAlreadyExceedsMaxAttempts('beanstalkd', Object(Illuminate\Queue\Jobs\BeanstalkdJob), 1)
#1 /home/forge/Altpocket.io/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(267): Illuminate\Queue\Worker->process('beanstalkd', Object(Illuminate\Queue\Jobs\BeanstalkdJob), Object(Illuminate\Queue\WorkerOptions))
#2 /home/forge/Altpocket.io/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(113): Illuminate\Queue\Worker->runJob(Object(Illuminate\Queue\Jobs\BeanstalkdJob), 'beanstalkd', Object(Illuminate\Queue\WorkerOptions))
#3 /home/forge/Altpocket.io/vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php(101): Illuminate\Queue\Worker->daemon('beanstalkd', 'default', Object(Illuminate\Queue\WorkerOptions))
#4 /home/forge/Altpocket.io/vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php(84): Illuminate\Queue\Console\WorkCommand->runWorker('beanstalkd', 'default')
#5 [internal function]: Illuminate\Queue\Console\WorkCommand->fire()
#6 /home/forge/Altpocket.io/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(29): call_user_func_array(Array, Array)
#7 /home/forge/Altpocket.io/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(87): Illuminate\Container\BoundMethod::Illuminate\Container\{closure}()
#8 /home/forge/Altpocket.io/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(31): Illuminate\Container\BoundMethod::callBoundMethod(Object(Illuminate\Foundation\Application), Array, Object(Closure))
#9 /home/forge/Altpocket.io/vendor/laravel/framework/src/Illuminate/Container/Container.php(539): Illuminate\Container\BoundMethod::call(Object(Illuminate\Foundation\Application), Array, Array, NULL)
#10 /home/forge/Altpocket.io/vendor/laravel/framework/src/Illuminate/Console/Command.php(182): Illuminate\Container\Container->call(Array)
#11 /home/forge/Altpocket.io/vendor/symfony/console/Command/Command.php(240): Illuminate\Console\Command->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\Console\OutputStyle))
#12 /home/forge/Altpocket.io/vendor/laravel/framework/src/Illuminate/Console/Command.php(167): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\Console\OutputStyle))
#13 /home/forge/Altpocket.io/vendor/symfony/console/Application.php(860): Illuminate\Console\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#14 /home/forge/Altpocket.io/vendor/symfony/console/Application.php(218): Symfony\Component\Console\Application->doRunCommand(Object(Illuminate\Queue\Console\WorkCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#15 /home/forge/Altpocket.io/vendor/symfony/console/Application.php(122): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#16 /home/forge/Altpocket.io/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(122): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#17 /home/forge/Altpocket.io/artisan(35): Illuminate\Foundation\Console\Kernel->handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#18 {main}
Here is my job:
<?php
namespace App\Jobs;
use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use App\Events\PushEvent;
use Cache;
class ImportBittrex implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
/**
* Create a new job instance.
*
* @return void
*/
protected $userid;
protected $withdraws;
protected $cachekey;
public $tries = 1;
public $timeout = 0;
public function __construct($userid, $withdraws)
{
$this->userid = $userid;
$this->withdraws = $withdraws;
}
/**
* Execute the job.
*
* @return void
*/
public function handle()
{
$this->cachekey = 'Import-Bittrex2'.$this->userid;
if(Cache::get($this->cachekey) !== null) {
event(new PushEvent('You already have an import running!', 'error', $this->userid));
return $this->userid;
}
Cache::put($this->cachekey, 1, 5);
app('App\Http\Controllers\ImportController')->importDepositsB($this->userid);
app('App\Http\Controllers\ImportController')->importTradesB($this->userid);
app('App\Http\Controllers\ImportController')->insertBuysB($this->userid);
app('App\Http\Controllers\ImportController')->importWithdrawsB($this->userid, $this->withdraws);
app('App\Http\Controllers\ImportController')->insertSellsB($this->userid);
app('App\Http\Controllers\ImportController')->importBalancesB($this->userid);
app('App\Http\Controllers\ImportController')->safeBittrexCheck($this->userid);
Cache::forget('investments'.$this->userid);
Cache::forget('b_investments'.$this->userid);
Cache::forget('deposits'.$this->userid);
Cache::forget('withdraws'.$this->userid);
Cache::forget('balances'.$this->userid);
Cache::forget('balances-summed'.$this->userid);
Cache::forget('deposits'.$this->userid);
Cache::forget('withdraws'.$this->userid);
Cache::forget($this->cachekey);
}
}
Here is my worker on laravel forge:
https://i.imgur.com/lz22zMX.png
What is wrong here? Why does this keep happening.
Basicially in the first function run in the job it will check if the user has a valid api key combination and if it doesnt it catches it and throws an error like so:
https://i.imgur.com/zldnUnT.png
Please help me I'm losing my mind.
来源:https://stackoverflow.com/questions/47416437/laravel-laravel-forge-returns-maxattemptsexceededexception-even-when-tries