Added system polling

This commit is contained in:
2023-07-26 19:44:07 +10:00
parent c23b5ebfc2
commit 4e44e2e266
19 changed files with 733 additions and 88 deletions

View File

@@ -34,14 +34,14 @@ class CommBinkpSend extends Command
*/
public function handle(): void
{
Log::info('CBS:- Call BINKP send');
$mo = Mailer::where('name',self::ID)->singleOrFail();
$ao = Address::findFTN($this->argument('ftn'));
if (! $ao)
throw new ModelNotFoundException('Unknown node: '.$this->argument('ftn'));
Job::dispatchSync($ao,$mo);
Log::info(sprintf('CBS:- Call BINKP send for %s',$ao->ftn));
$mo = Mailer::where('name',self::ID)->singleOrFail();
Job::dispatch($ao,$mo);
}
}

View File

@@ -34,14 +34,14 @@ class CommEMSISend extends Command
*/
public function handle(): void
{
Log::info('CES:- Call EMSI send');
$mo = Mailer::where('name',self::ID)->singleOrFail();
$ao = Address::findFTN($this->argument('ftn'));
if (! $ao)
throw new ModelNotFoundException('Unknown node: '.$this->argument('ftn'));
Job::dispatchSync($ao,$mo);
Log::info(sprintf('CES:- Call EMSI send for %s',$ao->ftn));
$mo = Mailer::where('name',self::ID)->singleOrFail();
Job::dispatch($ao,$mo);
}
}

View File

@@ -0,0 +1,50 @@
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use App\Models\Job;
class JobList extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'job:list';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Detail list of items in the queue';
/**
* Execute the console command.
*/
public function handle()
{
$lastq = NULL;
foreach (Job::orderBy('queue')->orderBy('created_at')->cursor() as $o) {
if ($o->queue !== $lastq) {
$this->alert(sprintf('Queue: %s',$o->queue));
$lastq = $o->queue;
}
$this->info(sprintf('%s-%d: %s[%s] - %d tries (Created: %s,Timeout: %s,Next: %s)',
$o->uuid,
$o->id,
$o->display_name,
$o->command->subject,
$o->attempts,
$o->created_at,
$o->retry_until ?: '-',
$o->reserved_at ?: '-',
));
}
}
}

View File

@@ -0,0 +1,52 @@
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Log;
use App\Jobs\MailSend as Job;
class MailSend extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'mail:send'
.' {--T|type=normal : Send crash, normal or both mail}';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Trigger a poll to each node with mail queued';
/**
* Execute the console command.
*/
public function handle()
{
switch ($this->option('type')) {
case 'crash':
Log::info('CML:- Triggering polls to send CRASH mail');
Job::dispatchSync(TRUE);
break;
case 'normal':
Log::info('CML:- Triggering polls to send NORMAL mail');
Job::dispatchSync(FALSE);
break;
case 'all':
Log::info('CML:- Triggering polls to send ALL mail');
Job::dispatchSync(NULL);
break;
default:
$this->error('Specify -T crash, normal or all');
}
}
}