Skip to content

Commit be7e431

Browse files
author
Robert Kummer
authored
Merge pull request #3 from rokde/master
documentation and scripts updated
2 parents ee42fc6 + 0dcbce5 commit be7e431

File tree

4 files changed

+23
-13
lines changed

4 files changed

+23
-13
lines changed

Dockerfile

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,11 @@ ENV PYTHON_VERSION=2.7.12-r0
66
ENV PY_PIP_VERSION=8.1.2-r0
77
ENV SUPERVISOR_VERSION=3.3.1
88

9-
ENV CONNECTION=default
10-
ENV QUEUE=default
9+
ENV QUEUE_CONNECTION=redis
10+
ENV QUEUE_NAME=default
11+
12+
# Install pdo if you want to use database queue
13+
RUN docker-php-ext-install pdo pdo_mysql
1114

1215
# Install supervisor
1316
RUN apk update && apk add -u python=$PYTHON_VERSION py-pip=$PY_PIP_VERSION

README.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,9 @@
1-
# docker-laravel-queue-worker
1+
# Laravel Queue Worker
2+
3+
A docker image for working with queues being monitored by supervisor as recommended by laravel.
4+
5+
## Environment Configuration
6+
7+
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`.
8+
9+
The default queue name in laravel is called `default`. So we configured the `QUEUE_NAME` environment variable to this value.

init.sh

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
11
#!/bin/sh
22

3-
if [ -z "$CONNECTION" ]; then
4-
CONNECTION="default"
3+
if [ -z "$QUEUE_CONNECTION" ]; then
4+
QUEUE_CONNECTION="redis"
55
fi
66

7-
if [ -Z "$QUEUE" ]; then
8-
QUEUE="default"
7+
if [ -z "$QUEUE_NAME" ]; then
8+
QUEUE_NAME="default"
99
fi
1010

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

15-
#rm /etc/supervisor/conf.d/laravel-worker.conf.tpl
16-
1715
supervisord --nodaemon --configuration /etc/supervisor/supervisord.conf

laravel-worker.conf.tpl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@ nodaemon=true
33

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

0 commit comments

Comments
 (0)