PHPackages                             foxxmd/laravel-elasticbeanstalk-queue-worker - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Queues &amp; Workers](/categories/queues)
4. /
5. foxxmd/laravel-elasticbeanstalk-queue-worker

ActiveLibrary[Queues &amp; Workers](/categories/queues)

foxxmd/laravel-elasticbeanstalk-queue-worker
============================================

Deploy your Laravel application as a queue worker on AWS ElasticBeanstalk

2.0.1(1y ago)5493.5k↓13.3%13[3 issues](https://github.com/FoxxMD/laravel-elasticbeanstalk-queue-worker/issues)MITPHP

Since Nov 11Pushed 1y ago5 watchersCompare

[ Source](https://github.com/FoxxMD/laravel-elasticbeanstalk-queue-worker)[ Packagist](https://packagist.org/packages/foxxmd/laravel-elasticbeanstalk-queue-worker)[ RSS](/packages/foxxmd-laravel-elasticbeanstalk-queue-worker/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (8)Dependencies (2)Versions (9)Used By (0)

Laravel 6 - 12.x Queue Worker for Elastic Beanstalk
===================================================

[](#laravel-6---12x-queue-worker-for-elastic-beanstalk)

*Use your Laravel application as a worker to consume queues on AWS Elasticbeanstalk*

Laravel provides a [wonderful array](https://laravel.com/docs/12.x/queues) of drivers for consuming queues within your application as well as [some documentation](https://laravel.com/docs/12.x/queues#supervisor-configuration) on how to manage your application with [Supervisord](http://supervisord.org/) when it is acting as a worker.

Unfortunately that's where the documentation ends. There is no guidance on how to manage multiple workers from a devops context which is a huge bummer. But don't worry fam I've got your covered.

**This package enables your Laravel application to manage itself, as a worker, in an [AWS Elasticbeanstalk](https://aws.amazon.com/elasticbeanstalk/) environment.**

**It provides these features:**

- **Automated installation of supervisor on first-time deployment**
- **Automatic updating of supervisor configuration upon deployment**
- **Two supervisor configuration deployment options:**
    - **Parsing of EB environmental variables to generate supervisor config**
    - **Or using a pre-built supervisor config supplied in project**

Amazon Linux 1 is deprecated and Amazon Linux 2023 is recommended
-----------------------------------------------------------------

[](#amazon-linux-1-is-deprecated-and-amazon-linux-2023-is-recommended)

Amazon Linux 1 (AL1) is already retired, even Amazon Linux 2 (AL2) will soon going to be unsupported too, so it's recommended to migrate to use Amazon Linux 2023 (AL2023) Starts from this release will only support AL2023, please use previous releases for use in AL2, with this release will also drop support for Laravel 5 (PHP 7) since EB only support starting from PHP 8.1

Let's get down to business
==========================

[](#lets-get-down-to-business)

Installation
------------

[](#installation)

Require this package

```
composer require "foxxmd/laravel-elasticbeanstalk-queue-worker"
```

or for Amazon Linux 2,

```
composer require "foxxmd/laravel-elasticbeanstalk-queue-worker@^1.0"
```

**After installing the package you can either:**

Publish using artisan

```
php artisan vendor:publish --tag=ebworker
```

**OR**

Copy everything from `src/.ebextensions` into your own `.ebextensions` folder and everything from `src/.platform` into your own `.platform` folder manually

**Note:** This library only consists of the EB deploy steps -- the provider is only for a convenience -- so if you want to you can modify/consolidate the `.ebextensions` / `.platform` folder if you're not into me overwriting your stuff.

Don't forget to add +x permission to the EB Platform Hooks scripts ([no longer required for Amazon Linux platform that released on or after April 29, 2022](https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/platforms-linux-extend.hooks.html#platforms-linux-extend.hooks.more))

```
find .platform -type f -iname "*.sh" -exec chmod +x {} +
```

Configuration
-------------

[](#configuration)

### Enable Worker Mode

[](#enable-worker-mode)

In order for worker deployment to be active you **must** add this environmental to your elasticbeanstalk environment configuration:

```
IS_WORKER = true
```

**If this variable is false or not present the deployment will not run**

### Set Queue Driver / Connection

[](#set-queue-driver--connection)

Set the [driver](https://laravel.com/docs/12.x/queues#driver-prerequisites) in your your EB environmental variables:

```
QUEUE_CONNECTION = [driver]
```

### Add Queues

[](#add-queues)

All queues are configured using EB environmental variables with the following syntax:

**Note**: brackets are placeholders only, do not use them in your actual configuration

```
queue[QueueName]     = [driver]   # Required. The name of the queue that should be run. Value is driver/connection name
[QueueName]NumProcs  = [value]       # Optional. The number of instances supervisor should run for this queue. Defaults to 1
[QueueName]Tries     = [value]       # Optional. The number of times the worker should attempt to run in the event an unexpected exit code occurs. Defaults to 5
[QueueName]Sleep     = [value]       # Optional. The number of seconds the worker should sleep if no new jobs are in the queue. Defaults to 5
[QueueName]StartSecs = [value]       # Optional. How long a job should run for to be considered successful. Defaults to 1
[QueueName]Delay     = [value]       # Optional. Time in seconds a job should be delayed before returning to the ready queue. Defaults to 0
```

Add one `queue[QueueName] = [driver]` entry in your EB environmental variables for each queue you want to run. The rest of the parameters are optional.

That's it! On your next deploy supervisor will have its configuration updated/generated and start chugging along on your queues.

Using Your Own `supervisord.conf`
---------------------------------

[](#using-your-own-supervisordconf)

Using your own, pre-built supervisor config file is easy too.

Simply set the location of the file in the published `elasticbeanstalkworker.php` config file:

```
