spatie / laravel-dynamic-servers
动态创建和销毁服务器
1.1.0
2024-05-10 12:05 UTC
Requires
- php: ^8.2
- illuminate/contracts: ^10.0|^11.0
- illuminate/http: ^10.0|^11.0
- spatie/laravel-package-tools: ^1.13.3
Requires (Dev)
- guzzlehttp/guzzle: ^7.5
- nunomaduro/collision: ^7.0|^8.0
- nunomaduro/larastan: ^2.2
- orchestra/testbench: ^8.0|^9.0
- pestphp/pest: ^v2.34
- pestphp/pest-plugin-laravel: ^2.4
- phpunit/phpunit: ^9.5|^10.5|^11.0
- spatie/pest-plugin-test-time: ^1.1.1|^2.0
- vlucas/phpdotenv: ^5.4.1
README
此包可以帮助您在需要时启动和停止服务器。主要用例是启动额外的服务器来帮助您处理队列上的工作负载。
您可以将此视为具有5%功能的基于PHP的Kubernetes版本,但涵盖了80%的用例。对于大多数PHP和Laravel开发者来说,此包也更容易学习和使用。
通常,在您的托管提供商处,您会准备一个服务器快照,该快照将在启动新服务器时用作模板。
配置此包后,启动额外服务器就像这样简单
// typically, in a service provider use Laravel\Horizon\WaitTimeCalculator; use Spatie\DynamicServers\Facades\DynamicServers; use Spatie\DynamicServers\Support\DynamicServersManager; /* * The package will call the closure passed * to `determineServerCount` every minute */ DynamicServers::determineServerCount(function(DynamicServersManager $servers) { /* * First, we'll calculate the number of servers needed. * * In this example, we will take a look at Horizon's * reported waiting time. Of course, in your project you can * calculate the number of servers needed however you want. */ $waitTimeInMinutes = app(WaitTimeCalculator::class)->calculate('default'); $numberOfServersNeeded = round($waitTimeInMinutes / 10); /* * Next, we will pass the number of servers needed to the `ensure` method. * * If there currently are less that that number of servers available, * the package will start new ones. * * If there are currently more than that number of servers running, * the package will stop a few servers. */ $servers->ensure($numberOfServersNeeded); });
开箱即用,此包支持UpCloud。您可以创建自己的服务器提供商以添加对您最喜欢的托管服务的支持。
支持我们
我们投入了大量资源来创建一流的开放式源代码包。您可以通过购买我们的付费产品之一来支持我们。
我们非常感谢您从家乡给我们寄来明信片,说明您正在使用我们的哪些包。您可以在我们的联系页面上找到我们的地址。我们将在我们的虚拟明信片墙上发布收到的所有明信片。
文档
所有文档都可在我们的文档网站上找到。
测试
composer test
变更日志
请参阅CHANGELOG了解最近更改的更多信息。
贡献
请参阅CONTRIBUTING了解详细信息。
安全漏洞
请查看我们的安全策略,了解如何报告安全漏洞。
致谢
这个包背后的想法是...由流和Jason McCreary在基于队列工作负载启动工作进程服务器的博客文章启发。
许可协议
MIT许可协议(MIT)。有关更多信息,请参阅许可文件。