Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@ ENV PYTHON_VERSION=2.7.12-r0
ENV PY_PIP_VERSION=8.1.2-r0
ENV SUPERVISOR_VERSION=3.3.1

ENV CONNECTION=default
ENV QUEUE=default
ENV QUEUE_CONNECTION=redis
ENV QUEUE_NAME=default

# Install pdo if you want to use database queue
RUN docker-php-ext-install pdo pdo_mysql

# Install supervisor
RUN apk update && apk add -u python=$PYTHON_VERSION py-pip=$PY_PIP_VERSION
Expand Down
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,9 @@
# docker-laravel-queue-worker
# Laravel Queue Worker

A docker image for working with queues being monitored by supervisor as recommended by laravel.

## Environment Configuration

Running with redis you can configure your `QUEUE_CONNECTION` environment variable to match your redis link. In our case the link is called `redis` so the default value will be `redis`.

The default queue name in laravel is called `default`. So we configured the `QUEUE_NAME` environment variable to this value.
14 changes: 6 additions & 8 deletions init.sh
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
#!/bin/sh

if [ -z "$CONNECTION" ]; then
CONNECTION="default"
if [ -z "$QUEUE_CONNECTION" ]; then
QUEUE_CONNECTION="redis"
fi

if [ -Z "$QUEUE" ]; then
QUEUE="default"
if [ -z "$QUEUE_NAME" ]; then
QUEUE_NAME="default"
fi

sed -e "s~%%CONNECTION%%~$CONNECTION~" \
-e "s~%%QUEUE%%~$QUEUE~" \
sed -e "s~%%QUEUE_CONNECTION%%~$QUEUE_CONNECTION~" \
-e "s~%%QUEUE_NAME%%~$QUEUE_NAME~" \
/etc/supervisor/conf.d/laravel-worker.conf.tpl > /etc/supervisor/supervisord.conf

#rm /etc/supervisor/conf.d/laravel-worker.conf.tpl

supervisord --nodaemon --configuration /etc/supervisor/supervisord.conf
5 changes: 3 additions & 2 deletions laravel-worker.conf.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ nodaemon=true

[program:laravel-worker]
process_name=%(program_name)s_%(process_num)02d
command=php /var/www/app/artisan queue:work %%CONNECTION%% --queue=%%QUEUE%%
command=php /var/www/app/artisan queue:work %%QUEUE_CONNECTION%% --queue=%%QUEUE_NAME%%
autostart=true
autorestart=true
numprocs=1
startretries=3000
startretries=10
stdout_events_enabled=1