Skip to content

Commit 7edd034

Browse files
committed
fix: wait for redis to be up
1 parent 1d6dd9e commit 7edd034

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

containers/php/entrypoint.sh

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,14 @@
22

33
set -e
44

5-
wait_for_services() {
5+
wait_for_php_fpm() {
66
wait-for "${PHP_HOST:?Missing PHP_HOST}:${PHP_PORT:?Missing PHP_PORT}" -t 60
77
}
88

9+
wait_for_redis() {
10+
wait-for "${REDIS_HOST:?Missing REDIS_HOST}:${REDIS_PORT:-6379}" -t 60
11+
}
12+
913
optimize() {
1014
if [ "$APP_ENV" != "local" ]; then
1115
php artisan optimize
@@ -21,17 +25,18 @@ if [ "$1" = "php-fpm" ]; then
2125
if [ "$(id -u)" = '0' ]; then
2226
chown -R www-data:www-data storage
2327
fi
28+
wait_for_redis
2429
exec "$@"
2530
elif [ "$1" = "scheduler" ]; then
26-
wait_for_services
31+
wait_for_php_fpm
2732
optimize
2833
exec su -s /bin/sh -c "php artisan schedule:work --quiet" www-data
2934
elif [ "$1" = "worker" ]; then
30-
wait_for_services
35+
wait_for_php_fpm
3136
optimize
3237
exec su -s /bin/sh -c "php artisan queue:work --tries=3 --timeout=1800" www-data
3338
elif [ "$1" = "nightwatch" ]; then
34-
wait_for_services
39+
wait_for_php_fpm
3540
optimize
3641
exec su -s /bin/sh -c "php artisan nightwatch:agent --listen-on 0.0.0.0:2407" www-data
3742
else

docker-compose.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ x-app: &app
77
UID: ${UID:-1000}
88
GID: ${GID:-1000}
99
restart: unless-stopped
10+
depends_on:
11+
- redis
1012
extra_hosts:
1113
- "host.docker.internal:host-gateway"
1214
volumes:

0 commit comments

Comments
 (0)