Skip to content

Commit f718099

Browse files
authored
Support health-check for all container modes (#88)
1 parent 61fa07f commit f718099

14 files changed

+66
-42
lines changed

FrankenPHP.Alpine.Dockerfile

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ RUN apk update; \
7373
curl \
7474
wget \
7575
nano \
76-
git \
76+
git \
7777
ncdu \
7878
procps \
7979
ca-certificates \
@@ -154,6 +154,7 @@ COPY --link --chown=${USER}:${USER} deployment/supervisord.conf /etc/supervisor/
154154
COPY --link --chown=${USER}:${USER} deployment/octane/FrankenPHP/supervisord.frankenphp.conf /etc/supervisor/conf.d/
155155
COPY --link --chown=${USER}:${USER} deployment/supervisord.*.conf /etc/supervisor/conf.d/
156156
COPY --link --chown=${USER}:${USER} deployment/start-container /usr/local/bin/start-container
157+
COPY --link --chown=${USER}:${USER} deployment/healthcheck /usr/local/bin/healthcheck
157158
COPY --link --chown=${USER}:${USER} deployment/php.ini ${PHP_INI_DIR}/conf.d/99-octane.ini
158159

159160
# FrankenPHP embedded PHP configuration
@@ -166,7 +167,7 @@ RUN composer install \
166167
--no-dev \
167168
&& composer clear-cache
168169

169-
RUN chmod +x /usr/local/bin/start-container
170+
RUN chmod +x /usr/local/bin/start-container /usr/local/bin/healthcheck
170171

171172
RUN cat deployment/utilities.sh >> ~/.bashrc
172173

@@ -177,4 +178,4 @@ EXPOSE 2019
177178

178179
ENTRYPOINT ["start-container"]
179180

180-
HEALTHCHECK --start-period=5s --interval=2s --timeout=5s --retries=8 CMD php artisan octane:status || exit 1
181+
HEALTHCHECK --start-period=5s --interval=2s --timeout=5s --retries=8 CMD healthcheck || exit 1

FrankenPHP.Dockerfile

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ RUN apt-get update; \
7575
curl \
7676
wget \
7777
nano \
78-
git \
78+
git \
7979
ncdu \
8080
procps \
8181
ca-certificates \
@@ -155,6 +155,7 @@ COPY --link --chown=${USER}:${USER} deployment/supervisord.conf /etc/supervisor/
155155
COPY --link --chown=${USER}:${USER} deployment/octane/FrankenPHP/supervisord.frankenphp.conf /etc/supervisor/conf.d/
156156
COPY --link --chown=${USER}:${USER} deployment/supervisord.*.conf /etc/supervisor/conf.d/
157157
COPY --link --chown=${USER}:${USER} deployment/start-container /usr/local/bin/start-container
158+
COPY --link --chown=${USER}:${USER} deployment/healthcheck /usr/local/bin/healthcheck
158159
COPY --link --chown=${USER}:${USER} deployment/php.ini ${PHP_INI_DIR}/conf.d/99-octane.ini
159160

160161
# FrankenPHP embedded PHP configuration
@@ -167,7 +168,7 @@ RUN composer install \
167168
--no-dev \
168169
&& composer clear-cache
169170

170-
RUN chmod +x /usr/local/bin/start-container
171+
RUN chmod +x /usr/local/bin/start-container /usr/local/bin/healthcheck
171172

172173
RUN cat deployment/utilities.sh >> ~/.bashrc
173174

@@ -178,4 +179,4 @@ EXPOSE 2019
178179

179180
ENTRYPOINT ["start-container"]
180181

181-
HEALTHCHECK --start-period=5s --interval=2s --timeout=5s --retries=8 CMD php artisan octane:status || exit 1
182+
HEALTHCHECK --start-period=5s --interval=2s --timeout=5s --retries=8 CMD healthcheck || exit 1

RoadRunner.Alpine.Dockerfile

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ RUN apk update; \
7070
curl \
7171
wget \
7272
nano \
73-
git \
73+
git \
7474
ncdu \
7575
procps \
7676
ca-certificates \
@@ -152,6 +152,7 @@ COPY --link --chown=${USER}:${USER} deployment/supervisord.*.conf /etc/superviso
152152
COPY --link --chown=${USER}:${USER} deployment/php.ini ${PHP_INI_DIR}/conf.d/99-octane.ini
153153
COPY --link --chown=${USER}:${USER} deployment/octane/RoadRunner/.rr.prod.yaml ./.rr.yaml
154154
COPY --link --chown=${USER}:${USER} deployment/start-container /usr/local/bin/start-container
155+
COPY --link --chown=${USER}:${USER} deployment/healthcheck /usr/local/bin/healthcheck
155156

156157
RUN composer install \
157158
--classmap-authoritative \
@@ -165,7 +166,7 @@ RUN if composer show | grep spiral/roadrunner-cli >/dev/null; then \
165166
echo "`spiral/roadrunner-cli` package is not installed. Exiting..."; exit 1; \
166167
fi
167168

168-
RUN chmod +x rr /usr/local/bin/start-container
169+
RUN chmod +x rr /usr/local/bin/start-container /usr/local/bin/healthcheck
169170

170171
RUN cat deployment/utilities.sh >> ~/.bashrc
171172

@@ -174,4 +175,4 @@ EXPOSE 6001
174175

175176
ENTRYPOINT ["start-container"]
176177

177-
HEALTHCHECK --start-period=5s --interval=2s --timeout=5s --retries=8 CMD php artisan octane:status || exit 1
178+
HEALTHCHECK --start-period=5s --interval=2s --timeout=5s --retries=8 CMD healthcheck || exit 1

RoadRunner.Dockerfile

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ RUN apt-get update; \
7272
curl \
7373
wget \
7474
nano \
75-
git \
75+
git \
7676
ncdu \
7777
procps \
7878
ca-certificates \
@@ -154,6 +154,7 @@ COPY --link --chown=${USER}:${USER} deployment/supervisord.*.conf /etc/superviso
154154
COPY --link --chown=${USER}:${USER} deployment/php.ini ${PHP_INI_DIR}/conf.d/99-octane.ini
155155
COPY --link --chown=${USER}:${USER} deployment/octane/RoadRunner/.rr.prod.yaml ./.rr.yaml
156156
COPY --link --chown=${USER}:${USER} deployment/start-container /usr/local/bin/start-container
157+
COPY --link --chown=${USER}:${USER} deployment/healthcheck /usr/local/bin/healthcheck
157158

158159
RUN composer install \
159160
--classmap-authoritative \
@@ -167,7 +168,7 @@ RUN if composer show | grep spiral/roadrunner-cli >/dev/null; then \
167168
echo "`spiral/roadrunner-cli` package is not installed. Exiting..."; exit 1; \
168169
fi
169170

170-
RUN chmod +x rr /usr/local/bin/start-container
171+
RUN chmod +x rr /usr/local/bin/start-container /usr/local/bin/healthcheck
171172

172173
RUN cat deployment/utilities.sh >> ~/.bashrc
173174

@@ -176,4 +177,4 @@ EXPOSE 6001
176177

177178
ENTRYPOINT ["start-container"]
178179

179-
HEALTHCHECK --start-period=5s --interval=2s --timeout=5s --retries=8 CMD php artisan octane:status || exit 1
180+
HEALTHCHECK --start-period=5s --interval=2s --timeout=5s --retries=8 CMD healthcheck || exit 1

Swoole.Alpine.Dockerfile

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ RUN apk update; \
7070
curl \
7171
wget \
7272
nano \
73-
git \
73+
git \
7474
ncdu \
7575
procps \
7676
ca-certificates \
@@ -152,6 +152,7 @@ COPY --link --chown=${USER}:${USER} deployment/octane/Swoole/supervisord.swoole.
152152
COPY --link --chown=${USER}:${USER} deployment/supervisord.*.conf /etc/supervisor/conf.d/
153153
COPY --link --chown=${USER}:${USER} deployment/php.ini ${PHP_INI_DIR}/conf.d/99-octane.ini
154154
COPY --link --chown=${USER}:${USER} deployment/start-container /usr/local/bin/start-container
155+
COPY --link --chown=${USER}:${USER} deployment/healthcheck /usr/local/bin/healthcheck
155156

156157
RUN composer install \
157158
--classmap-authoritative \
@@ -160,12 +161,12 @@ RUN composer install \
160161
--no-dev \
161162
&& composer clear-cache
162163

163-
RUN chmod +x /usr/local/bin/start-container
164+
RUN chmod +x /usr/local/bin/start-container /usr/local/bin/healthcheck
164165

165166
RUN cat deployment/utilities.sh >> ~/.bashrc
166167

167168
EXPOSE 8000
168169

169170
ENTRYPOINT ["start-container"]
170171

171-
HEALTHCHECK --start-period=5s --interval=2s --timeout=5s --retries=8 CMD php artisan octane:status || exit 1
172+
HEALTHCHECK --start-period=5s --interval=2s --timeout=5s --retries=8 CMD healthcheck || exit 1

Swoole.Dockerfile

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ RUN apt-get update; \
7272
curl \
7373
wget \
7474
nano \
75-
git \
75+
git \
7676
ncdu \
7777
procps \
7878
ca-certificates \
@@ -154,6 +154,7 @@ COPY --link --chown=${USER}:${USER} deployment/octane/Swoole/supervisord.swoole.
154154
COPY --link --chown=${USER}:${USER} deployment/supervisord.*.conf /etc/supervisor/conf.d/
155155
COPY --link --chown=${USER}:${USER} deployment/php.ini ${PHP_INI_DIR}/conf.d/99-octane.ini
156156
COPY --link --chown=${USER}:${USER} deployment/start-container /usr/local/bin/start-container
157+
COPY --link --chown=${USER}:${USER} deployment/healthcheck /usr/local/bin/healthcheck
157158

158159
RUN composer install \
159160
--classmap-authoritative \
@@ -162,12 +163,12 @@ RUN composer install \
162163
--no-dev \
163164
&& composer clear-cache
164165

165-
RUN chmod +x /usr/local/bin/start-container
166+
RUN chmod +x /usr/local/bin/start-container /usr/local/bin/healthcheck
166167

167168
RUN cat deployment/utilities.sh >> ~/.bashrc
168169

169170
EXPOSE 8000
170171

171172
ENTRYPOINT ["start-container"]
172173

173-
HEALTHCHECK --start-period=5s --interval=2s --timeout=5s --retries=8 CMD php artisan octane:status || exit 1
174+
HEALTHCHECK --start-period=5s --interval=2s --timeout=5s --retries=8 CMD healthcheck || exit 1

deployment/healthcheck

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/usr/bin/env sh
2+
3+
set -e
4+
5+
container_mode=${CONTAINER_MODE:-"http"}
6+
7+
if [ "${container_mode}" = "http" ]; then
8+
php artisan octane:status
9+
elif [ "${container_mode}" = "horizon" ]; then
10+
php artisan horizon:status
11+
elif [ "${container_mode}" = "scheduler" ]; then
12+
supervisorctl status scheduler:scheduler_00
13+
elif [ "${container_mode}" = "worker" ]; then
14+
supervisorctl status worker:worker_00
15+
else
16+
echo "Container mode mismatched."
17+
exit 1
18+
fi

deployment/octane/FrankenPHP/supervisord.frankenphp.conf

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[program:octane]
2-
process_name=%(program_name)s_%(process_num)02d
2+
process_name=%(program_name)s_%(process_num)s
33
command=php %(ENV_ROOT)s/artisan octane:start --server=frankenphp --host=0.0.0.0 --port=8000 --admin-port=2019
44
; command=php %(ENV_ROOT)s/artisan octane:start --server=frankenphp --host=localhost --port=443 --admin-port=2019 --https --http-redirect
55
user=%(ENV_USER)s
@@ -12,7 +12,7 @@ stderr_logfile=/dev/stderr
1212
stderr_logfile_maxbytes=0
1313

1414
[program:horizon]
15-
process_name=%(program_name)s_%(process_num)02d
15+
process_name=%(program_name)s_%(process_num)s
1616
command=php %(ENV_ROOT)s/artisan horizon
1717
user=%(ENV_USER)s
1818
autostart=%(ENV_WITH_HORIZON)s
@@ -24,7 +24,7 @@ stderr_logfile_maxbytes=200MB
2424
stopwaitsecs=3600
2525

2626
[program:scheduler]
27-
process_name=%(program_name)s_%(process_num)02d
27+
process_name=%(program_name)s_%(process_num)s
2828
command=supercronic -overlapping /etc/supercronic/laravel
2929
user=%(ENV_USER)s
3030
autostart=%(ENV_WITH_SCHEDULER)s
@@ -35,7 +35,7 @@ stderr_logfile=%(ENV_ROOT)s/storage/logs/scheduler.log
3535
stderr_logfile_maxbytes=200MB
3636

3737
[program:clear-scheduler-cache]
38-
process_name=%(program_name)s_%(process_num)02d
38+
process_name=%(program_name)s_%(process_num)s
3939
command=php %(ENV_ROOT)s/artisan schedule:clear-cache
4040
user=%(ENV_USER)s
4141
autostart=%(ENV_WITH_SCHEDULER)s

deployment/octane/RoadRunner/supervisord.roadrunner.conf

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[program:octane]
2-
process_name=%(program_name)s_%(process_num)02d
2+
process_name=%(program_name)s_%(process_num)s
33
command=php %(ENV_ROOT)s/artisan octane:start --server=roadrunner --host=0.0.0.0 --port=8000 --rpc-port=6001 --rr-config=%(ENV_ROOT)s/.rr.yaml
44
user=%(ENV_USER)s
55
autostart=true
@@ -11,7 +11,7 @@ stderr_logfile=/dev/stderr
1111
stderr_logfile_maxbytes=0
1212

1313
[program:horizon]
14-
process_name=%(program_name)s_%(process_num)02d
14+
process_name=%(program_name)s_%(process_num)s
1515
command=php %(ENV_ROOT)s/artisan horizon
1616
user=%(ENV_USER)s
1717
autostart=%(ENV_WITH_HORIZON)s
@@ -23,7 +23,7 @@ stderr_logfile_maxbytes=200MB
2323
stopwaitsecs=3600
2424

2525
[program:scheduler]
26-
process_name=%(program_name)s_%(process_num)02d
26+
process_name=%(program_name)s_%(process_num)s
2727
command=supercronic -overlapping /etc/supercronic/laravel
2828
user=%(ENV_USER)s
2929
autostart=%(ENV_WITH_SCHEDULER)s
@@ -34,7 +34,7 @@ stderr_logfile=%(ENV_ROOT)s/storage/logs/scheduler.log
3434
stderr_logfile_maxbytes=200MB
3535

3636
[program:clear-scheduler-cache]
37-
process_name=%(program_name)s_%(process_num)02d
37+
process_name=%(program_name)s_%(process_num)s
3838
command=php %(ENV_ROOT)s/artisan schedule:clear-cache
3939
user=%(ENV_USER)s
4040
autostart=%(ENV_WITH_SCHEDULER)s

deployment/octane/Swoole/supervisord.swoole.conf

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[program:octane]
2-
process_name=%(program_name)s_%(process_num)02d
2+
process_name=%(program_name)s_%(process_num)s
33
command=php %(ENV_ROOT)s/artisan octane:start --server=swoole --host=0.0.0.0 --port=8000
44
user=%(ENV_USER)s
55
autostart=true
@@ -11,7 +11,7 @@ stderr_logfile=/dev/stderr
1111
stderr_logfile_maxbytes=0
1212

1313
[program:horizon]
14-
process_name=%(program_name)s_%(process_num)02d
14+
process_name=%(program_name)s_%(process_num)s
1515
command=php %(ENV_ROOT)s/artisan horizon
1616
user=%(ENV_USER)s
1717
autostart=%(ENV_WITH_HORIZON)s
@@ -23,7 +23,7 @@ stderr_logfile_maxbytes=200MB
2323
stopwaitsecs=3600
2424

2525
[program:scheduler]
26-
process_name=%(program_name)s_%(process_num)02d
26+
process_name=%(program_name)s_%(process_num)s
2727
command=supercronic -overlapping /etc/supercronic/laravel
2828
user=%(ENV_USER)s
2929
autostart=%(ENV_WITH_SCHEDULER)s
@@ -34,7 +34,7 @@ stderr_logfile=%(ENV_ROOT)s/storage/logs/scheduler.log
3434
stderr_logfile_maxbytes=200MB
3535

3636
[program:clear-scheduler-cache]
37-
process_name=%(program_name)s_%(process_num)02d
37+
process_name=%(program_name)s_%(process_num)s
3838
command=php %(ENV_ROOT)s/artisan schedule:clear-cache
3939
user=%(ENV_USER)s
4040
autostart=%(ENV_WITH_SCHEDULER)s

0 commit comments

Comments
 (0)