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:
42
app/Console/Commands/AddParametersTrait.php
Normal file
42
app/Console/Commands/AddParametersTrait.php
Normal 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();
|
||||
}
|
||||
}
|
||||
39
app/Console/Commands/FailedTableCommand.php
Normal file
39
app/Console/Commands/FailedTableCommand.php
Normal 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);
|
||||
}
|
||||
}
|
||||
20
app/Console/Commands/FlushFailedCommand.php
Normal file
20
app/Console/Commands/FlushFailedCommand.php
Normal 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;
|
||||
}
|
||||
14
app/Console/Commands/ForgetFailedCommand.php
Normal file
14
app/Console/Commands/ForgetFailedCommand.php
Normal 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;
|
||||
}
|
||||
20
app/Console/Commands/ListFailedCommand.php
Normal file
20
app/Console/Commands/ListFailedCommand.php
Normal 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;
|
||||
}
|
||||
20
app/Console/Commands/RestartCommand.php
Normal file
20
app/Console/Commands/RestartCommand.php
Normal 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;
|
||||
}
|
||||
14
app/Console/Commands/RetryCommand.php
Normal file
14
app/Console/Commands/RetryCommand.php
Normal 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;
|
||||
}
|
||||
39
app/Console/Commands/TableCommand.php
Normal file
39
app/Console/Commands/TableCommand.php
Normal 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);
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user