You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+39-20
Original file line number
Diff line number
Diff line change
@@ -1,12 +1,12 @@
1
-
# Laravel 5 Queue Worker for Elastic Beanstalk
1
+
# Laravel 5 - 9.x Queue Worker for Elastic Beanstalk
2
2
3
-
*Use your L5 application as a worker to consume queues on AWS Elasticbeanstalk*
3
+
*Use your Laravel application as a worker to consume queues on AWS Elasticbeanstalk*
4
4
5
5
Laravel provides a [wonderful array](https://laravel.com/docs/5.1/queues) of drivers for consuming queues within your application as well as [some documentation](https://laravel.com/docs/5.1/queues#supervisor-configuration) on how to manage your application with [Supervisord](http://supervisord.org/) when it is acting as a worker.
6
6
7
7
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.
8
8
9
-
**This package enables your L5 application to manage itself, as a worker, in an [AWS Elasticbeanstalk](https://aws.amazon.com/elasticbeanstalk/) environment.**
9
+
**This package enables your Laravel application to manage itself, as a worker, in an [AWS Elasticbeanstalk](https://aws.amazon.com/elasticbeanstalk/) environment.**
10
10
11
11
**It provides these features:**
12
12
@@ -16,20 +16,31 @@ Unfortunately that's where the documentation ends. There is no guidance on how t
16
16
***Parsing of EB environmental variables to generate supervisor config**
17
17
***Or using a pre-built supervisor config supplied in project**
18
18
19
-
# Let's get down to business
19
+
## Amazon Linux 1 deprecation
20
+
21
+
Amazon Linux 1 (AL1) is going to be unsupported soon, it is advised to migrate to use Amazon Linux 2 (AL2)
Copy everything from `src/.ebextensions` into your own `.ebextensions` folder manually
57
+
Copy everything from `src/.ebextensions` into your own `.ebextensions` folder and everything from `src/.platform` into your own `.platform` folder manually
58
+
59
+
**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.
47
60
48
-
**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` folder if you're not into me overwriting your stuff.
61
+
Don't forget to add +x permission to the EB Platform Hooks scripts
@@ -54,29 +71,33 @@ Copy everything from `src/.ebextensions` into your own `.ebextensions` folder ma
54
71
55
72
In order for worker deployment to be active you **must** add this environmental to your elasticbeanstalk environment configuration:
56
73
57
-
```
74
+
```bash
58
75
IS_WORKER = true
59
76
```
60
77
61
78
**If this variable is false or not present the deployment will not run**
62
79
63
-
### Set Queue Driver
80
+
### Set Queue Driver / Connection
64
81
65
82
Set the [driver](https://laravel.com/docs/5.1/queues#introduction) in your your EB environmental variables:
66
83
67
-
```
84
+
```bash
68
85
QUEUE_DRIVER = [driver]
69
86
```
70
87
71
-
**Note: If no `QUEUE_DRIVER` key is present in your EB environmental variables then `beanstalkd` will be used.**
88
+
Since Laravel 5.7 the variable name got changed so will also support the new name:
89
+
90
+
```bash
91
+
QUEUE_CONNECTION = [driver]
92
+
```
72
93
73
94
### Add Queues
74
95
75
96
All queues are configured using EB environmental variables with the following syntax:
76
97
77
98
**Note**: brackets are placeholders only, do not use them in your actual configuration
78
99
79
-
```
100
+
```bash
80
101
queue[QueueName] = [queueName] # Required. The name of the queue that should be run.
81
102
[QueueName]NumProcs = [value] # Optional. The number of instances supervisor should run for this queue. Defaults to 1
82
103
[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
@@ -113,14 +134,16 @@ return array(
113
134
114
135
Now during the deploy process your configuration file will be used instead of generating one.
115
136
116
-
Note: you can check `eb-activity.log` for your EB environment to verify if the deploy process detected and deployed your file. Search for `Starting supervisor configuration parsing.` in the log.
137
+
Note: you can check `eb-hooks.log` for your EB environment to verify if the deploy process detected and deployed your file. Search for `Starting supervisor configuration parsing.` in the log.
117
138
118
139
# But how does it work?
119
140
120
141
Glad you asked. It's a simple process but required a ton of trial and error to get right (kudos to AWS for their lack of documentation)
121
142
122
143
EB applications can contain a [folder](https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/ebextensions.html) that provides advanced configuration for an EB environment, called `.ebextensions`.
123
144
145
+
EB applications since AL2 can contain [platform hooks](https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/platforms-linux-extend.html) that provides hook scripts for an EB environment, called `.platform`.
146
+
124
147
This package uses AWS commands files in this folder to detect, install, and update supervisor and its configuration and then run it for you.
125
148
126
149
### 1. Ingress Supervisor rules
@@ -133,7 +156,7 @@ Supervisor requires port 9001 to be open if you want to access its web monitor.
133
156
134
157
Otherwise `parseConfig.php` looks for a json file generated earlier that contains all of the environmental variables configured for elastic beanstalk. It then parses out any queue configurations found (see `Add Queues`) section above and generates a supervisor program for each as well as supplying each program with all the environmental variables set for EB. The program to be generated looks like this:
0 commit comments