Skip to content

Commit 504553f

Browse files
committed
Update readme with user-supplied config options and instructions
#6
1 parent 18defab commit 504553f

File tree

1 file changed

+34
-8
lines changed

1 file changed

+34
-8
lines changed

README.md

Lines changed: 34 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ Unfortunately that's where the documentation ends. There is no guidance on how t
1212

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

1719
# Let's get down to business
1820

@@ -72,8 +74,6 @@ QUEUE_DRIVER = [driver]
7274

7375
All queues are configured using EB envronmental variables with the following syntax:
7476

75-
**Note**: keys/values are currently **case-sensitive**
76-
7777
**Note**: brackets are placeholders only, do not use them in your actual configuration
7878

7979
```
@@ -88,6 +88,32 @@ Add one `queue[QueueName] = [queueName]` entry in your EB environmental variable
8888

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

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.
105+
* EX:
106+
* Absolute Path: /Users/dev/coding/MyProject/config/mysupervisord.conf
107+
* Path to use: config/mysupervisord.conf
108+
*/
109+
'supervisorConfigPath' => 'config/mysupervisord.conf`
110+
);
111+
```
112+
113+
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+
91117
# But how does it work?
92118

93119
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.
102128

103129
### 2. Parse Queue Configuration
104130

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:
106134

107135
```
108136
[program:$queue]
@@ -125,12 +153,12 @@ Now a bash script `workerDeploy.sh` checks for `IS_WORKER=TRUE` in the EB enviro
125153
* If it is found
126154
* And there is no `init.d` script
127155
* 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
129157
* Supervisor is started
130158
* Supervisor is set to start at boot
131159
* And there is an `init.d` script
132160
* Supervisor is stopped
133-
* The generated configuration is copied over the old one at `/etc/supervisord.conf`
161+
* Configuration is parsed
134162
* Laravel artisan is used to restart the queue to refresh the daemon
135163
* Supervisor is restarted with the new configuration
136164

@@ -140,9 +168,7 @@ Now a bash script `workerDeploy.sh` checks for `IS_WORKER=TRUE` in the EB enviro
140168
This is almost verbatim how I have things setup for another project so some usage is limited because of how it was originally written:
141169

142170
* Queue driver defaults to beanstalkd if not explicitly set
143-
* Queue parameters in the EB environental variables are case-sensitive
144171
* 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
146172

147173
All of these are simple fixes though! Check out issues to see these and more and if you need them please make a PR!
148174

0 commit comments

Comments
 (0)