corley/maintenance-bundle
Composer 安装命令:
composer require corley/maintenance-bundle
包简介
Corley Maintenance Bundle
README 文档
README
A unified way of putting a web application under maintenance using web server strategies. The maintenance mode will cut off all requests and it will replies with a static html file and a 503 header (Service Unavailable).
Those conditions will ensure that a load balancer cut an instance off during a maintenance
Install
In composer.json add the requirement.
The current version requires at least PHP 8.1 and a supported (as at time of release) version of Symfony (4.4, 5.4, 6.0 and 6.1).
"require": { "corley/maintenance-bundle": "^0.5" }
To support earlier versions e.g. SF 3.4, 4.2, 4.3, 5.1 etc or PHP greater than 7.2 but less than 8.1 you will need to use:
"require": { "corley/maintenance-bundle": "^0.4" }
To support earlier versions still, e.g. SF 2.x, 3.3, 4.1 etc or PHP less than 7.2 you will need to use:
"require": { "corley/maintenance-bundle": "^0.2" }
This version can also be used for more recent Symfony versions, e.g. with 3.4 or 4.4 but is not compatible with Symfony 5 - only 0.3 or greater can be used there because of changes to the event structure in Symfony 5.0.
For pre-Flex applications register the bundle in AppKernel.php
public function registerBundles() { ... $bundles = array( ... new Corley\MaintenanceBundle\CorleyMaintenanceBundle(), ); ... return $bundles; }
For projects built with recent versions of Flex, a default recipe will be generated which will add the bundle to your bundles.php. In older versions of Flex you may need to do this yourself
Corley\MaintenanceBundle\CorleyMaintenanceBundle::class => ['all' => true],
Maintenance mode
When you want to put your web application under maintenance
bin/console corley:maintenance:lock on
Restore the application status
bin/console corley:maintenance:lock off
Configure your web server
If you use Apache2 you have to add a few lines to your .htaccess, for nginx just add dedicated
lines to web app configuration.
Make sure that those lines precede any other rewrite rule.
The mod_rewrite module in Apache2 has to be installed and enabled.
In order to obtain your configuration options use the console
Apache2
bin/console corley:maintenance:dump-apache
Nginx
bin/console corley:maintenance:dump-nginx
Configuration
You can configure the bundle in order to change the default behaviour (all options have a default value)
For projects not using Flex
# config.yml corley_maintenance: page: %kernel.root_dir%/../web/maintenance.dist.html hard_lock: lock.html symlink: false web: %kernel.root_dir%/../web
For Flex projects
# config/packages/corley.yml corley_maintenance: page: %kernel.project_dir%/templates/maintenance.dist.html hard_lock: lock.html symlink: false
Options:
pageis the original maintenance page (default:vendor/corley/maintenance-bundle/Corley/MaintenanceBundle/Resources/views/maintenance.html)symlinkIf you want to use symlinks instead hardcopy strategy (default: hardcopy)hard_lockIs the name used in order to lock the website (default:hard.lock)webpublic folder. Prior to 0.4 this defaulted to%kernel.root_dir%/../web, since 0.4.0 the new default is%kernel.project_dir%/publicas the%kernel.root_dir%parameter has been deprecated since Symfony 4.2, and was removed in 5.1. If your project's public folder is stillweb(or some other folder) set this in the config file.soft_lockIs the name used in order to lock the website (using app layer)whitelistAuthorized connections [soft-lock only]pathsA list of paths that skip the maintenance lockipsA list of ips that skip the maintenance lock
Soft locking
The soft locking strategy uses the php layer in order to lock down the website. This means that the application must work in order to lock down the web site.
The soft lock runs at kernel.request and stops other event propagation.
When you want to put your web application under maintenance using a soft-locking strategy:
bin/console corley:maintenance:soft-lock on
Restore the application status
bin/console corley:maintenance:soft-lock off
corley/maintenance-bundle 适用场景与选型建议
corley/maintenance-bundle 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 233.5k 次下载、GitHub Stars 达 22, 最近一次更新时间为 2015 年 07 月 31 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「maintenance」 「apache2」 「apache」 「nginx」 「Maintenance management」 「503」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 corley/maintenance-bundle 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 corley/maintenance-bundle 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 corley/maintenance-bundle 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Toolkit for starting a PHP application locally, with or without foreman, using the same config for PHP and Apache2/Nginx as on Heroku
An enhanced drop-in replacement for Laravel's maintenance mode
Maintenance page plugin
Neos Content Repository Helper to rebirth orphaned nodes
This package includes a script and fail2ban configuration that allows you to use fail2ban when utilizing AWS elastic load balancer (ELB) and an apache webserver.
Maintenance page, pretty and simple.
统计信息
- 总下载量: 233.5k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 23
- 点击次数: 40
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-07-31