Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support health-check for all container modes #88

Merged
merged 1 commit into from
Sep 7, 2024
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: 4 additions & 3 deletions FrankenPHP.Alpine.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ RUN apk update; \
curl \
wget \
nano \
git \
git \
ncdu \
procps \
ca-certificates \
Expand Down Expand Up @@ -154,6 +154,7 @@ COPY --link --chown=${USER}:${USER} deployment/supervisord.conf /etc/supervisor/
COPY --link --chown=${USER}:${USER} deployment/octane/FrankenPHP/supervisord.frankenphp.conf /etc/supervisor/conf.d/
COPY --link --chown=${USER}:${USER} deployment/supervisord.*.conf /etc/supervisor/conf.d/
COPY --link --chown=${USER}:${USER} deployment/start-container /usr/local/bin/start-container
COPY --link --chown=${USER}:${USER} deployment/healthcheck /usr/local/bin/healthcheck
COPY --link --chown=${USER}:${USER} deployment/php.ini ${PHP_INI_DIR}/conf.d/99-octane.ini

# FrankenPHP embedded PHP configuration
Expand All @@ -166,7 +167,7 @@ RUN composer install \
--no-dev \
&& composer clear-cache

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

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

Expand All @@ -177,4 +178,4 @@ EXPOSE 2019

ENTRYPOINT ["start-container"]

HEALTHCHECK --start-period=5s --interval=2s --timeout=5s --retries=8 CMD php artisan octane:status || exit 1
HEALTHCHECK --start-period=5s --interval=2s --timeout=5s --retries=8 CMD healthcheck || exit 1
7 changes: 4 additions & 3 deletions FrankenPHP.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ RUN apt-get update; \
curl \
wget \
nano \
git \
git \
ncdu \
procps \
ca-certificates \
Expand Down Expand Up @@ -155,6 +155,7 @@ COPY --link --chown=${USER}:${USER} deployment/supervisord.conf /etc/supervisor/
COPY --link --chown=${USER}:${USER} deployment/octane/FrankenPHP/supervisord.frankenphp.conf /etc/supervisor/conf.d/
COPY --link --chown=${USER}:${USER} deployment/supervisord.*.conf /etc/supervisor/conf.d/
COPY --link --chown=${USER}:${USER} deployment/start-container /usr/local/bin/start-container
COPY --link --chown=${USER}:${USER} deployment/healthcheck /usr/local/bin/healthcheck
COPY --link --chown=${USER}:${USER} deployment/php.ini ${PHP_INI_DIR}/conf.d/99-octane.ini

# FrankenPHP embedded PHP configuration
Expand All @@ -167,7 +168,7 @@ RUN composer install \
--no-dev \
&& composer clear-cache

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

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

Expand All @@ -178,4 +179,4 @@ EXPOSE 2019

ENTRYPOINT ["start-container"]

HEALTHCHECK --start-period=5s --interval=2s --timeout=5s --retries=8 CMD php artisan octane:status || exit 1
HEALTHCHECK --start-period=5s --interval=2s --timeout=5s --retries=8 CMD healthcheck || exit 1
7 changes: 4 additions & 3 deletions RoadRunner.Alpine.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ RUN apk update; \
curl \
wget \
nano \
git \
git \
ncdu \
procps \
ca-certificates \
Expand Down Expand Up @@ -152,6 +152,7 @@ COPY --link --chown=${USER}:${USER} deployment/supervisord.*.conf /etc/superviso
COPY --link --chown=${USER}:${USER} deployment/php.ini ${PHP_INI_DIR}/conf.d/99-octane.ini
COPY --link --chown=${USER}:${USER} deployment/octane/RoadRunner/.rr.prod.yaml ./.rr.yaml
COPY --link --chown=${USER}:${USER} deployment/start-container /usr/local/bin/start-container
COPY --link --chown=${USER}:${USER} deployment/healthcheck /usr/local/bin/healthcheck

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

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

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

Expand All @@ -174,4 +175,4 @@ EXPOSE 6001

ENTRYPOINT ["start-container"]

HEALTHCHECK --start-period=5s --interval=2s --timeout=5s --retries=8 CMD php artisan octane:status || exit 1
HEALTHCHECK --start-period=5s --interval=2s --timeout=5s --retries=8 CMD healthcheck || exit 1
7 changes: 4 additions & 3 deletions RoadRunner.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ RUN apt-get update; \
curl \
wget \
nano \
git \
git \
ncdu \
procps \
ca-certificates \
Expand Down Expand Up @@ -154,6 +154,7 @@ COPY --link --chown=${USER}:${USER} deployment/supervisord.*.conf /etc/superviso
COPY --link --chown=${USER}:${USER} deployment/php.ini ${PHP_INI_DIR}/conf.d/99-octane.ini
COPY --link --chown=${USER}:${USER} deployment/octane/RoadRunner/.rr.prod.yaml ./.rr.yaml
COPY --link --chown=${USER}:${USER} deployment/start-container /usr/local/bin/start-container
COPY --link --chown=${USER}:${USER} deployment/healthcheck /usr/local/bin/healthcheck

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

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

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

Expand All @@ -176,4 +177,4 @@ EXPOSE 6001

ENTRYPOINT ["start-container"]

HEALTHCHECK --start-period=5s --interval=2s --timeout=5s --retries=8 CMD php artisan octane:status || exit 1
HEALTHCHECK --start-period=5s --interval=2s --timeout=5s --retries=8 CMD healthcheck || exit 1
7 changes: 4 additions & 3 deletions Swoole.Alpine.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ RUN apk update; \
curl \
wget \
nano \
git \
git \
ncdu \
procps \
ca-certificates \
Expand Down Expand Up @@ -152,6 +152,7 @@ COPY --link --chown=${USER}:${USER} deployment/octane/Swoole/supervisord.swoole.
COPY --link --chown=${USER}:${USER} deployment/supervisord.*.conf /etc/supervisor/conf.d/
COPY --link --chown=${USER}:${USER} deployment/php.ini ${PHP_INI_DIR}/conf.d/99-octane.ini
COPY --link --chown=${USER}:${USER} deployment/start-container /usr/local/bin/start-container
COPY --link --chown=${USER}:${USER} deployment/healthcheck /usr/local/bin/healthcheck

RUN composer install \
--classmap-authoritative \
Expand All @@ -160,12 +161,12 @@ RUN composer install \
--no-dev \
&& composer clear-cache

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

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

EXPOSE 8000

ENTRYPOINT ["start-container"]

HEALTHCHECK --start-period=5s --interval=2s --timeout=5s --retries=8 CMD php artisan octane:status || exit 1
HEALTHCHECK --start-period=5s --interval=2s --timeout=5s --retries=8 CMD healthcheck || exit 1
7 changes: 4 additions & 3 deletions Swoole.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ RUN apt-get update; \
curl \
wget \
nano \
git \
git \
ncdu \
procps \
ca-certificates \
Expand Down Expand Up @@ -154,6 +154,7 @@ COPY --link --chown=${USER}:${USER} deployment/octane/Swoole/supervisord.swoole.
COPY --link --chown=${USER}:${USER} deployment/supervisord.*.conf /etc/supervisor/conf.d/
COPY --link --chown=${USER}:${USER} deployment/php.ini ${PHP_INI_DIR}/conf.d/99-octane.ini
COPY --link --chown=${USER}:${USER} deployment/start-container /usr/local/bin/start-container
COPY --link --chown=${USER}:${USER} deployment/healthcheck /usr/local/bin/healthcheck

RUN composer install \
--classmap-authoritative \
Expand All @@ -162,12 +163,12 @@ RUN composer install \
--no-dev \
&& composer clear-cache

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

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

EXPOSE 8000

ENTRYPOINT ["start-container"]

HEALTHCHECK --start-period=5s --interval=2s --timeout=5s --retries=8 CMD php artisan octane:status || exit 1
HEALTHCHECK --start-period=5s --interval=2s --timeout=5s --retries=8 CMD healthcheck || exit 1
18 changes: 18 additions & 0 deletions deployment/healthcheck
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/env sh

set -e

container_mode=${CONTAINER_MODE:-"http"}

if [ "${container_mode}" = "http" ]; then
php artisan octane:status
elif [ "${container_mode}" = "horizon" ]; then
php artisan horizon:status
elif [ "${container_mode}" = "scheduler" ]; then
supervisorctl status scheduler:scheduler_00
elif [ "${container_mode}" = "worker" ]; then
supervisorctl status worker:worker_00
else
echo "Container mode mismatched."
exit 1
fi
8 changes: 4 additions & 4 deletions deployment/octane/FrankenPHP/supervisord.frankenphp.conf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[program:octane]
process_name=%(program_name)s_%(process_num)02d
process_name=%(program_name)s_%(process_num)s
command=php %(ENV_ROOT)s/artisan octane:start --server=frankenphp --host=0.0.0.0 --port=8000 --admin-port=2019
; command=php %(ENV_ROOT)s/artisan octane:start --server=frankenphp --host=localhost --port=443 --admin-port=2019 --https --http-redirect
user=%(ENV_USER)s
Expand All @@ -12,7 +12,7 @@ stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0

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

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

[program:clear-scheduler-cache]
process_name=%(program_name)s_%(process_num)02d
process_name=%(program_name)s_%(process_num)s
command=php %(ENV_ROOT)s/artisan schedule:clear-cache
user=%(ENV_USER)s
autostart=%(ENV_WITH_SCHEDULER)s
Expand Down
8 changes: 4 additions & 4 deletions deployment/octane/RoadRunner/supervisord.roadrunner.conf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[program:octane]
process_name=%(program_name)s_%(process_num)02d
process_name=%(program_name)s_%(process_num)s
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
user=%(ENV_USER)s
autostart=true
Expand All @@ -11,7 +11,7 @@ stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0

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

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

[program:clear-scheduler-cache]
process_name=%(program_name)s_%(process_num)02d
process_name=%(program_name)s_%(process_num)s
command=php %(ENV_ROOT)s/artisan schedule:clear-cache
user=%(ENV_USER)s
autostart=%(ENV_WITH_SCHEDULER)s
Expand Down
8 changes: 4 additions & 4 deletions deployment/octane/Swoole/supervisord.swoole.conf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[program:octane]
process_name=%(program_name)s_%(process_num)02d
process_name=%(program_name)s_%(process_num)s
command=php %(ENV_ROOT)s/artisan octane:start --server=swoole --host=0.0.0.0 --port=8000
user=%(ENV_USER)s
autostart=true
Expand All @@ -11,7 +11,7 @@ stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0

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

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

[program:clear-scheduler-cache]
process_name=%(program_name)s_%(process_num)02d
process_name=%(program_name)s_%(process_num)s
command=php %(ENV_ROOT)s/artisan schedule:clear-cache
user=%(ENV_USER)s
autostart=%(ENV_WITH_SCHEDULER)s
Expand Down
16 changes: 8 additions & 8 deletions deployment/start-container
Original file line number Diff line number Diff line change
Expand Up @@ -14,34 +14,34 @@ initialStuff() {
php artisan config:cache; \
php artisan route:cache;

if [ ${running_migrations_and_seeders} = "true" ]; then
if [ "${running_migrations_and_seeders}" = "true" ]; then
echo "Running migrations and seeding database ..."
php artisan migrate --isolated --seed --force;
fi
}

if [ "$1" != "" ]; then
exec "$@"
elif [ ${container_mode} = "http" ]; then
elif [ "${container_mode}" = "http" ]; then
echo "Octane Server: $octane_server"
initialStuff
if [ ${octane_server} = "frankenphp" ]; then
if [ "${octane_server}" = "frankenphp" ]; then
exec /usr/bin/supervisord -c /etc/supervisor/conf.d/supervisord.frankenphp.conf
elif [ ${octane_server} = "swoole" ]; then
elif [ "${octane_server}" = "swoole" ]; then
exec /usr/bin/supervisord -c /etc/supervisor/conf.d/supervisord.swoole.conf
elif [ ${octane_server} = "roadrunner" ]; then
elif [ "${octane_server}" = "roadrunner" ]; then
exec /usr/bin/supervisord -c /etc/supervisor/conf.d/supervisord.roadrunner.conf
else
echo "Invalid Octane server supplied."
exit 1
fi
elif [ ${container_mode} = "horizon" ]; then
elif [ "${container_mode}" = "horizon" ]; then
initialStuff
exec /usr/bin/supervisord -c /etc/supervisor/conf.d/supervisord.horizon.conf
elif [ ${container_mode} = "scheduler" ]; then
elif [ "${container_mode}" = "scheduler" ]; then
initialStuff
exec /usr/bin/supervisord -c /etc/supervisor/conf.d/supervisord.scheduler.conf
elif [ ${container_mode} = "worker" ]; then
elif [ "${container_mode}" = "worker" ]; then
initialStuff
exec /usr/bin/supervisord -c /etc/supervisor/conf.d/supervisord.worker.conf
else
Expand Down
2 changes: 1 addition & 1 deletion deployment/supervisord.horizon.conf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[program:horizon]
process_name=%(program_name)s_%(process_num)02d
process_name=%(program_name)s_%(process_num)s
command=php %(ENV_ROOT)s/artisan horizon
user=%(ENV_USER)s
autostart=true
Expand Down
4 changes: 2 additions & 2 deletions deployment/supervisord.scheduler.conf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[program:scheduler]
process_name=%(program_name)s_%(process_num)02d
process_name=%(program_name)s_%(process_num)s
command=supercronic -overlapping /etc/supercronic/laravel
user=%(ENV_USER)s
autostart=true
Expand All @@ -10,7 +10,7 @@ stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0

[program:clear-scheduler-cache]
process_name=%(program_name)s_%(process_num)02d
process_name=%(program_name)s_%(process_num)s
command=php %(ENV_ROOT)s/artisan schedule:clear-cache
user=%(ENV_USER)s
autostart=true
Expand Down
2 changes: 1 addition & 1 deletion deployment/supervisord.worker.conf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[program:worker]
process_name=%(program_name)s_%(process_num)02d
process_name=%(program_name)s_%(process_num)s
command=%(ENV_WORKER_COMMAND)s
user=%(ENV_USER)s
autostart=true
Expand Down
Loading