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
***Parsing of EB environmental variables to generate supervisor config**
17
+
***Or using a pre-built supervisor config supplied in project**
16
18
17
19
# Let's get down to business
18
20
@@ -72,8 +74,6 @@ QUEUE_DRIVER = [driver]
72
74
73
75
All queues are configured using EB envronmental variables with the following syntax:
74
76
75
-
**Note**: keys/values are currently **case-sensitive**
76
-
77
77
**Note**: brackets are placeholders only, do not use them in your actual configuration
78
78
79
79
```
@@ -88,6 +88,32 @@ Add one `queue[QueueName] = [queueName]` entry in your EB environmental variable
88
88
89
89
That's it! On your next deploy supervisor will have its configuration updated/generated and start chugging along on your queues.
90
90
91
+
## Using Your Own `supervisord.conf`
92
+
93
+
Using your own, pre-built supervisor config file is easy too.
94
+
95
+
Simply set the location of the file in the published `elasticbeanstalkworker.php` config file:
96
+
97
+
```php
98
+
<?php
99
+
100
+
return array(
101
+
/*
102
+
* The path of the supervisord.conf file to be used INSTEAD OF generating one from environmental variables. Note that this can be null if you do not have one.
103
+
*
104
+
* This path is RELATIVE to the root of your application.
Now during the deploy process your configuration file will be used instead of generating one.
114
+
115
+
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.
116
+
91
117
# But how does it work?
92
118
93
119
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)
@@ -102,7 +128,9 @@ Supervisor requires port 9001 to be open if you want to access its web monitor.
102
128
103
129
### 2. Parse Queue Configuration
104
130
105
-
`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. The program to be generated looks like this:
131
+
`parseConfig.php` looks for either a user-supplied `supervisord.conf` file specified in configuration. If one exists then it is used.
132
+
133
+
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. The program to be generated looks like this:
106
134
107
135
```
108
136
[program:$queue]
@@ -125,12 +153,12 @@ Now a bash script `workerDeploy.sh` checks for `IS_WORKER=TRUE` in the EB enviro
125
153
* If it is found
126
154
* And there is no `init.d` script
127
155
* Supervisor is installed using pip and the custom `supervisord` init script in this project is copied to `/etc/init.d`
128
-
*The generated configuration is copied over the default one at `/etc/supervisord.conf`
156
+
*Configuration is parsed
129
157
* Supervisor is started
130
158
* Supervisor is set to start at boot
131
159
* And there is an `init.d` script
132
160
* Supervisor is stopped
133
-
*The generated configuration is copied over the old one at `/etc/supervisord.conf`
161
+
*Configuration is parsed
134
162
* Laravel artisan is used to restart the queue to refresh the daemon
135
163
* Supervisor is restarted with the new configuration
136
164
@@ -140,9 +168,7 @@ Now a bash script `workerDeploy.sh` checks for `IS_WORKER=TRUE` in the EB enviro
140
168
This is almost verbatim how I have things setup for another project so some usage is limited because of how it was originally written:
141
169
142
170
* Queue driver defaults to beanstalkd if not explicitly set
143
-
* Queue parameters in the EB environental variables are case-sensitive
144
171
* There is no way to generate a supervisor program without `--queue=[queue]` right now
145
-
* There is no way to use a pre-generated `supervisord.conf` file right now
146
172
147
173
All of these are simple fixes though! Check out issues to see these and more and if you need them please make a PR!
0 commit comments