bluepsyduck/symfony-process-manager
Composer 安装命令:
composer require bluepsyduck/symfony-process-manager
包简介
A process manager for Symfony processes, able to run them in parallel.
README 文档
README
This package provides a simple process manager class to be able to execute multiple processes with a specified limit of parallel processes. The class expects the processes to use the Symfony Process component.
Usage
The usage of the process manager is straight forward and best explained with an example.
<?php use BluePsyduck\SymfonyProcessManager\ProcessManager; use Symfony\Component\Process\Process; $numberOfParallelProcesses = 4; // The number of processes to execute in parallel. $pollInterval = 100; // The interval to use for polling the processes, in milliseconds. $processStartDelay = 0; // The time to delay the start of processes to space them out, in milliseconds. $processManager = new ProcessManager($numberOfParallelProcesses, $pollInterval, $processStartDelay); // Add some processes // Processes get executed automatically once they are added to the manager. // If the limit of parallel processes is reached, they are placed in a queue and wait for a process to finish. $processManager->addProcess(Process::fromShellCommandline('ls -l')); $processManager->addProcess(Process::fromShellCommandline('ls -l')); // Wait for all processes to finish $processManager->waitForAllProcesses();
Callbacks
The process manager allows for some callbacks to be specified, which get called depending on the state of a process.
- processStartCallback: Triggered before a process is started.
- processFinishCallback: Triggered when a process has finished.
- processTimeoutCallback: Triggered when a process timed out. Note that the processFinishCallback will be triggered afterwards as well.
- processCheckCallback: Triggered whenever a process is checked for completion. Note that this callback is called
periodically, but at least once, between the
processStartCallbackand theprocessFinishCallbackorprocessTimeoutCallbackrespectively.
Each callback gets the process instance which triggered the event passed as only parameter. Here is an example of
setting a processStartCallback:
<?php use BluePsyduck\SymfonyProcessManager\ProcessManager; use Symfony\Component\Process\Process; $processManager = new ProcessManager(); $processManager->setProcessStartCallback(function (Process $process): void { echo 'Starting process: ' . $process->getCommandLine(); }); $processManager->addProcess(Process::fromShellCommandline('ls -l')); $processManager->waitForAllProcesses();
bluepsyduck/symfony-process-manager 适用场景与选型建议
bluepsyduck/symfony-process-manager 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 816.88k 次下载、GitHub Stars 达 9, 最近一次更新时间为 2018 年 09 月 06 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「symfony」 「process」 「manager」 「parallel」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 bluepsyduck/symfony-process-manager 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 bluepsyduck/symfony-process-manager 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 bluepsyduck/symfony-process-manager 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Doctrine implementation of the MetaborStd (Statemachine) for PHP 8.2+
The file manager intended for using Laravel with CKEditor / TinyMCE / Colorbox
Shell command module for PHP.
The bundle for easy using json-rpc api on your project
Swoole server process management
Inbox pattern process implementation for your Laravel Applications
统计信息
- 总下载量: 816.88k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 9
- 点击次数: 28
- 依赖项目数: 3
- 推荐数: 0
其他信息
- 授权协议: GPL-3.0-or-later
- 更新时间: 2018-09-06