1616use Illuminate \Queue \Console \WorkCommand ;
1717use Illuminate \Queue \QueueManager ;
1818use Illuminate \Queue \Worker ;
19+ use Illuminate \Queue \WorkerOptions ;
1920use LukeWaite \LaravelQueueAwsBatch \Exceptions \JobNotFoundException ;
2021use LukeWaite \LaravelQueueAwsBatch \Exceptions \UnsupportedException ;
2122use LukeWaite \LaravelQueueAwsBatch \Queues \BatchQueue ;
@@ -27,7 +28,13 @@ class QueueWorkBatchCommand extends WorkCommand
2728
2829 protected $ description = 'Run a Job for the AWS Batch queue ' ;
2930
30- protected $ signature = 'queue:work-batch {connection} {job_id} {--tries=} ' ;
31+ protected $ signature = 'queue:work-batch
32+ {job_id : The job id in the database}
33+ {connection? : The name of the queue connection to work}
34+ {--memory=128 : The memory limit in megabytes}
35+ {--timeout=60 : The number of seconds a child process can run}
36+ {--tries=0 : Number of times to attempt a job before logging it failed} ' ;
37+
3138
3239 protected $ manager ;
3340 protected $ exceptions ;
@@ -41,6 +48,8 @@ public function __construct(QueueManager $manager, Worker $worker, Handler $exce
4148
4249 public function fire ()
4350 {
51+ $ this ->listenForEvents ();
52+
4453 try {
4554 $ this ->runJob ();
4655 } catch (\Exception $ e ) {
@@ -70,7 +79,7 @@ protected function runJob()
7079 // If we're able to pull a job off of the stack, we will process it and
7180 // then immediately return back out.
7281 if (!is_null ($ job )) {
73- $ this ->worker ->process (
82+ return $ this ->worker ->process (
7483 $ this ->manager ->getName ($ connectionName ),
7584 $ job ,
7685 $ this ->gatherWorkerOptions ()
@@ -80,4 +89,18 @@ protected function runJob()
8089 // If we hit this point, we haven't processed our job
8190 throw new JobNotFoundException ('No job was returned ' );
8291 }
92+
93+ /**
94+ * Gather all of the queue worker options as a single object.
95+ *
96+ * @return \Illuminate\Queue\WorkerOptions
97+ */
98+ protected function gatherWorkerOptions ()
99+ {
100+ return new WorkerOptions (
101+ 0 , $ this ->option ('memory ' ),
102+ $ this ->option ('timeout ' ), 0 ,
103+ $ this ->option ('tries ' ), false
104+ );
105+ }
83106}
0 commit comments