Skip to content

Instantly share code, notes, and snippets.

@ducxinh
Created July 9, 2018 10:27
Show Gist options
  • Save ducxinh/b85d7eacb708c281d4717b6c90876389 to your computer and use it in GitHub Desktop.
Save ducxinh/b85d7eacb708c281d4717b6c90876389 to your computer and use it in GitHub Desktop.
Setup supervisor in eb
## Installing Supervisor on AWS Elastic Beanstalk manually.
This gist may help you to install supervisor Manually on AWS Beanstalk host. I was enable to install and configure referring supervisor docs. Here are the steps by which I was able to use supervisor on my project.
> Note: I have performed this steps on Laravel project and my instance was Debian powered. You can change according to your requirement.
-----------------
* Check **python with easy_install** is installed
* Install **supervisor** > `$ easy_install supervisor`
* Create directory for supervisor workers > `mkdir /etc/supervisor/conf.d/`
* Create laravel worker file > `touch /etc/supervisor/conf.d/laravel-worker.conf`
* Add following contents to `laravel-worker.conf`
```shell
[program:laravel-worker]
process_name=%(program_name)s_%(process_num)02d
command=php /var/www/html/artisan queue:work --tries=3
autostart=true
autorestart=true
user=root
numprocs=5
redirect_stderr=true
stdout_logfile=/var/www/html/storage/worker.log
```
* Change `command` and `stdout_logfile` according to project setup
* Create **supervisor config** file > `touch /etc/supervisord.conf` and following contents to created file
```shell
; supervisor config file
[unix_http_server]
file=/var/run/supervisor.sock ; (the path to the socket file)
chmod=0700 ; sockef file mode (default 0700)
[supervisord]
logfile=/var/log/supervisor/supervisord.log ; (main log file;default $CWD/supervisord.log)
pidfile=/var/run/supervisord.pid ; (supervisord pidfile;default supervisord.pid)
childlogdir=/var/log/supervisor ; ('AUTO' child log dir, default $TEMP)
; the below section must remain in the config file for RPC
; (supervisorctl/web interface) to work, additional interfaces may be
; added by defining them in separate rpcinterface: sections
[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface
[supervisorctl]
serverurl=unix:///var/run/supervisor.sock ; use a unix:// URL for a unix socket
; The [include] section can just contain the "files" setting. This
; setting can list multiple files (separated by whitespace or
; newlines). It can also contain wildcards. The filenames are
; interpreted as relative to this file. Included files *cannot*
; include files themselves.
[include]
files = /etc/supervisor/conf.d/*.conf
; Change according to your configurations
```
* Create **log file for supervisor** as > `touch /var/log/supervisor/supervisord.log` if not exist
* **Restart** the supervisord as > `/usr/local/bin/supervisord -c /etc/supervisord.conf`
* **Reread** supervisorctl as > `/usr/local/bin/supervisorctl reread`
* **Update** supervisorctl as > `/usr/local/bin/supervisorctl update`
* **Start** laravel-worker and any other workers as > `/usr/local/bin/supervisorctl start laravel-worker:*`
* **Check status** whether workers are running as > `/usr/local/bin/supervisorctl status` you show see similar output as below
```log
laravel-worker:laravel-worker_00 RUNNING pid 10039, uptime 0:20:35
laravel-worker:laravel-worker_01 RUNNING pid 10040, uptime 0:20:35
laravel-worker:laravel-worker_02 RUNNING pid 10041, uptime 0:20:35
laravel-worker:laravel-worker_03 RUNNING pid 10042, uptime 0:20:35
laravel-worker:laravel-worker_04 RUNNING pid 10043, uptime 0:20:35
```
* Done :tada:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment