PMC-964 We need a new artisan command to manage the failed jobs, because we need to load the workspace configuration

This commit is contained in:
Roly Rudy Gutierrez Pinto
2019-07-19 09:56:20 -04:00
parent 5dcbd70771
commit 1deddc05d0
11 changed files with 218 additions and 40 deletions

View File

@@ -0,0 +1,42 @@
<?php
namespace App\Console\Commands;
use Maveriks\WebApplication;
trait AddParametersTrait
{
/**
* Create a new queue command.
*
* @return void
*/
public function __construct()
{
$this->signature .= '
{--workspace=workflow : ProcessMaker Indicates the workspace to be processed.}
{--processmakerPath=./ : ProcessMaker path.}
';
$this->description .= ' (ProcessMaker has extended this command)';
parent::__construct();
}
/**
* Execute the console command.
*
* @return void
*/
public function handle()
{
$workspace = $this->option('workspace');
if (!empty($workspace)) {
$webApplication = new WebApplication();
$webApplication->setRootDir($this->option('processmakerPath'));
$webApplication->loadEnvironment($workspace);
}
parent::handle();
}
}

View File

@@ -0,0 +1,39 @@
<?php
namespace App\Console\Commands;
use Illuminate\Filesystem\Filesystem;
use Illuminate\Queue\Console\FailedTableCommand as BaseFailedTableCommand;
use Illuminate\Support\Composer;
class FailedTableCommand extends BaseFailedTableCommand
{
/**
* The console command name.
*
* @var string
*/
protected $signature = 'queue:failed-table';
/**
* This contains the necessary code to add parameters.
*/
use AddParametersTrait;
/**
* Create a new queue failed-table command.
*
* @return void
*/
public function __construct(Filesystem $files, Composer $composer)
{
$this->signature .= '
{--workspace=workflow : ProcessMaker Indicates the workspace to be processed.}
{--processmakerPath=./ : ProcessMaker path.}
';
$this->description .= ' (ProcessMaker has extended this command)';
parent::__construct($files, $composer);
}
}

View File

@@ -0,0 +1,20 @@
<?php
namespace App\Console\Commands;
use Illuminate\Queue\Console\FlushFailedCommand as BaseFlushFailedCommand;
class FlushFailedCommand extends BaseFlushFailedCommand
{
/**
* The console command name.
*
* @var string
*/
protected $signature = 'queue:flush';
/**
* This contains the necessary code to add parameters.
*/
use AddParametersTrait;
}

View File

@@ -0,0 +1,14 @@
<?php
namespace App\Console\Commands;
use Illuminate\Queue\Console\ForgetFailedCommand as BaseForgetFailedCommand;
class ForgetFailedCommand extends BaseForgetFailedCommand
{
/**
* This contains the necessary code to add parameters.
*/
use AddParametersTrait;
}

View File

@@ -0,0 +1,20 @@
<?php
namespace App\Console\Commands;
use Illuminate\Queue\Console\ListFailedCommand as BaseListFailedCommand;
class ListFailedCommand extends BaseListFailedCommand
{
/**
* The console command name.
*
* @var string
*/
protected $signature = 'queue:failed';
/**
* This contains the necessary code to add parameters.
*/
use AddParametersTrait;
}

View File

@@ -0,0 +1,20 @@
<?php
namespace App\Console\Commands;
use Illuminate\Queue\Console\RestartCommand as BaseRestartCommand;
class RestartCommand extends BaseRestartCommand
{
/**
* The console command name.
*
* @var string
*/
protected $signature = 'queue:restart';
/**
* This contains the necessary code to add parameters.
*/
use AddParametersTrait;
}

View File

@@ -0,0 +1,14 @@
<?php
namespace App\Console\Commands;
use Illuminate\Queue\Console\RetryCommand as BaseRetryCommand;
class RetryCommand extends BaseRetryCommand
{
/**
* This contains the necessary code to add parameters.
*/
use AddParametersTrait;
}

View File

@@ -0,0 +1,39 @@
<?php
namespace App\Console\Commands;
use Illuminate\Filesystem\Filesystem;
use Illuminate\Queue\Console\TableCommand as BaseTableCommand;
use Illuminate\Support\Composer;
class TableCommand extends BaseTableCommand
{
/**
* The console command name.
*
* @var string
*/
protected $signature = 'queue:table';
/**
* This contains the necessary code to add parameters.
*/
use AddParametersTrait;
/**
* Create a new queue table command.
*
* @return void
*/
public function __construct(Filesystem $files, Composer $composer)
{
$this->signature .= '
{--workspace=workflow : ProcessMaker Indicates the workspace to be processed.}
{--processmakerPath=./ : ProcessMaker path.}
';
$this->description .= ' (ProcessMaker has extended this command)';
parent::__construct($files, $composer);
}
}

View File

@@ -4,11 +4,12 @@ namespace App\Console\Commands;
use Illuminate\Queue\Console\WorkCommand as BaseWorkCommand;
use Illuminate\Queue\Worker;
use Maveriks\WebApplication;
class WorkCommand extends BaseWorkCommand
{
use AddParametersTrait;
/**
* Create a new queue work command.
*
@@ -27,33 +28,4 @@ class WorkCommand extends BaseWorkCommand
parent::__construct($worker);
}
/**
* Run the worker instance.
*
* @param string $connection
* @param string $queue
*/
protected function runWorker($connection, $queue)
{
$workspace = $this->option('workspace');
if (!empty($workspace)) {
$webApplication = new WebApplication();
$webApplication->setRootDir($this->option('processmakerPath'));
$webApplication->loadEnvironment($workspace);
}
parent::runWorker($connection, $queue);
}
/**
* Gather all of the queue worker options as a single object.
*
* @return \Illuminate\Queue\WorkerOptions
*/
protected function gatherWorkerOptions()
{
$options = parent::gatherWorkerOptions();
return $options;
}
}