ueberdosis/laravel-docker-health-check
Composer 安装命令:
composer require ueberdosis/laravel-docker-health-check
包简介
README 文档
README
A simple package that makes it easier to work with Laravel and Docker in production.
Installation
Install it with composer:
composer require ueberdosis/laravel-docker-health-check
Add the Middleware to your app/Http/Kernel.php:
class Kernel extends HttpKernel { /** * The application's global HTTP middleware stack. * * These middleware are run during every request to your application. * * @var array */ protected $middleware = [ // ... \Ueberdosis\DockerHealthCheck\Middleware\ClearCacheOnInitialRequest::class, ]; // ... }
Update your health check script to curl the newly registered route /docker-health-check. The following is an example health check script, please update your own implementation:
#!/usr/bin/env bash set -e if [ $(curl -o /dev/null -L -s -w "%{http_code}\n" http://localhost/docker-health-check) = "200" ]; then exit 0 else exit 1 fi
What problem is this package solving?
When using Laravel with Docker in production you would normally write a huge entrypoint script that runs migrations, clears caches and so on. But clearing caches in this entrypoint script doesn't work well. Why?
Well, the orchestrator waits for the Laravel container to become healthy before directing actual traffic to it. So when you update your stack, the old container will handle all the traffic at the moment when you call php artisan view:clear in your entrypoint up to the moment when the new container is healthy. When traffic hits the site in that moment, the cache will be rebuilt in the old container.
This is a huge pain on big dockerized Laravel apps. This package will clear caches on the first request to a new container by using a temporary file in the app root.
And it conveniently registers a nice /docker-health-check route for you that returns a response with status code 200 for your health check script.
License
MIT
ueberdosis/laravel-docker-health-check 适用场景与选型建议
ueberdosis/laravel-docker-health-check 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 4k 次下载、GitHub Stars 达 6, 最近一次更新时间为 2021 年 02 月 04 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 ueberdosis/laravel-docker-health-check 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 ueberdosis/laravel-docker-health-check 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 4k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 6
- 点击次数: 3
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2021-02-04