|
| 1 | +# Commands |
| 2 | + |
| 3 | +Here are all the commands you can use with the Queue library. |
| 4 | + |
| 5 | +--- |
| 6 | + |
| 7 | +Available options: |
| 8 | + |
| 9 | +- [queue:publish](#queuePublish) |
| 10 | +- [queue:job](#queueJob) |
| 11 | +- [queue:work](#queueWork) |
| 12 | +- [queue:stop](#queueStop) |
| 13 | +- [queue:clear](#queueClear) |
| 14 | +- [queue:failed](#queueFailed) |
| 15 | +- [queue:retry](#queueRetry) |
| 16 | +- [queue:forget](#queueForget) |
| 17 | +- [queue:flush](#queueFlush) |
| 18 | + |
| 19 | + |
| 20 | +### queue:publish |
| 21 | + |
| 22 | +Allows you to publish a configuration class in the application namespace. |
| 23 | + |
| 24 | +#### Example |
| 25 | + |
| 26 | + php spark queue:publish |
| 27 | + |
| 28 | +### queue:job |
| 29 | + |
| 30 | +Generates a new job file. |
| 31 | + |
| 32 | +#### Arguments |
| 33 | + |
| 34 | +* `name` - The job class name. |
| 35 | + |
| 36 | +#### Options |
| 37 | + |
| 38 | +* `--namespace` - Set root namespace. Default: "APP_NAMESPACE". |
| 39 | +* `--suffix` - Append the component title to the class name (e.g. Email => EmailJob). |
| 40 | +* `--force` - Force overwrite existing file. |
| 41 | + |
| 42 | +#### Example |
| 43 | + |
| 44 | + php spark queue:job Email |
| 45 | + |
| 46 | +It will generate the `Email` class in the `App\Jobs` namespace. |
| 47 | + |
| 48 | +### queue:work |
| 49 | + |
| 50 | +Allows you to consume jobs from a specific queue. |
| 51 | + |
| 52 | +#### Arguments |
| 53 | + |
| 54 | +* `queueName` - Name of the queue we will work with. |
| 55 | + |
| 56 | +#### Options |
| 57 | + |
| 58 | +* `-sleep` - Wait time between the next check for available job when the queue is empty. Default value: `10` (seconds). |
| 59 | +* `-rest` - Rest time between the jobs in the queue. Default value: `0` (seconds) |
| 60 | +* `-max-jobs` - The maximum number of jobs to handle before worker should exit. Disabled by default. |
| 61 | +* `-max-time` - The maximum number of seconds worker should run. Disabled by default. |
| 62 | +* `-memory` - The maximum memory in MB that worker can take. Default value: `128`, |
| 63 | +* `-tries` - The number of attempts after which the job will be considered as failed. Overrides settings from the Job class. Disabled by default. |
| 64 | +* `-retry-after` - The number of seconds after which the job is to be restarted in case of failure. Overrides settings from the Job class. Disabled by default. |
| 65 | +* `--stop-when-empty` - Stop when the queue is empty. |
| 66 | + |
| 67 | +#### Example |
| 68 | + |
| 69 | + php spark queue:work emails -max-jobs 5 |
| 70 | + |
| 71 | +It will listen for 5 jobs from the `emails` queue and then stop. |
| 72 | + |
| 73 | +### queue:stop |
| 74 | + |
| 75 | +Allows you to stop a specific queue in a safe way. It does this as soon as the job that is running in the queue is completed. |
| 76 | + |
| 77 | +#### Arguments |
| 78 | + |
| 79 | +* `queueName` - Name of the queue we will work with. |
| 80 | + |
| 81 | +#### Example |
| 82 | + |
| 83 | + php spark queue:stop emails |
| 84 | + |
| 85 | +### queue:clear |
| 86 | + |
| 87 | +Allows you to remove all jobs from a specific queue. |
| 88 | + |
| 89 | +#### Arguments |
| 90 | + |
| 91 | +* `queueName` - Name of the queue we will work with. |
| 92 | + |
| 93 | +#### Example |
| 94 | + |
| 95 | + php spark queue:clear emails |
| 96 | + |
| 97 | +### queue:failed |
| 98 | + |
| 99 | +Allows you to view all failed jobs. Also only from a specific queue |
| 100 | + |
| 101 | +#### Options |
| 102 | + |
| 103 | +* `-queue` - Queue name. |
| 104 | + |
| 105 | +#### Example |
| 106 | + |
| 107 | + php spark queue:failed -queue emails |
| 108 | + |
| 109 | +It will list failed jobs from the `emails` queue. |
| 110 | + |
| 111 | +### queue:retry |
| 112 | + |
| 113 | +Allows you to retry failed jobs back to the queue. |
| 114 | + |
| 115 | +#### Arguments |
| 116 | + |
| 117 | +* `id` - ID of the failed job or "all" for all failed jobs. |
| 118 | + |
| 119 | +#### Options |
| 120 | + |
| 121 | +* `-queue` - Queue name. |
| 122 | + |
| 123 | +#### Example |
| 124 | + |
| 125 | + php spark queue:retry all -queue emails |
| 126 | + |
| 127 | +It will retry all the failed jobs from the `emails` queue. |
| 128 | + |
| 129 | +### queue:forget |
| 130 | + |
| 131 | +Allows you to delete the failed job by ID |
| 132 | + |
| 133 | +#### Arguments |
| 134 | + |
| 135 | +* `id` - ID of the failed job. |
| 136 | + |
| 137 | +#### Example |
| 138 | + |
| 139 | + php spark queue:forget 123 |
| 140 | + |
| 141 | +### queue:flush |
| 142 | + |
| 143 | +Allows you to delete many failed jobs at once. Based on the failed date and queue. |
| 144 | + |
| 145 | +#### Options |
| 146 | + |
| 147 | +* `-hours` - Number of hours. |
| 148 | +* `-queue` - Queue name. |
| 149 | + |
| 150 | +#### Example |
| 151 | + |
| 152 | + php spark queue:flush -hours 6 |
| 153 | + |
| 154 | +It will delete all failed jobs older than 6 hours. |
0 commit comments