win32service/win32servicebundle
Composer 安装命令:
composer require win32service/win32servicebundle
包简介
Bundle for integrate the win32service/service-library into a Symfony Project
README 文档
README
The bundle for use Service-Library and Win32Service PHP ext into a Symfony Project.
Install
composer require win32service/win32servicebundle
Configure
Add file config/win32service.yaml with this content:
win32_service: windows_local_encoding: ISO-8859-15 # The windows local encoding for convert the string UTF-8 from configuration to the local encoding. logging_extra: # This configuration enable a processor for Monolog enable: false # Enable a processor for add the thread number into the extra fields channels: # The list of channels whom the processor add the thread number. If empty, the thread number is added for all channels. - ref1 services: # Prototype - service_id: "" # The service id. If `thread_count` > 1, you can use `%d` to define the place of the thread number machine: "" # the machine name for this service. displayed_name: "" # The friendly name of the service. If `thread_count` > 1, you can use `%d` to define the place of the thread number script_path: ~ # the script name. If not defined, the integrated execute command is used. script_params: "" # the arguments for the script. if `thread_count` > 1, you can use `%d` to define the place of the thread number run_max: 1000 # number of loop before exit thread_count: 1 # the number of this service need to register. Use `%d` into `service_id`, `displayed_name` and `script_params` for contains the service number. description: "" # the service description delayed_start: false # If true the starting for the service is delayed exit: # Settings for the exit mode graceful: true # if false, the exit fire the recovery action code: 0 # If graceful is true, this value must not be 0 user: # The User set on the service account: ~ # the account name password: ~ # the password recovery: enable: false # The recovery action is disabled delay: 60000 # The delay before run action (in millisecond) action1: 0 # The action for the first fail action2: 0 # The action for the second fail action3: 0 # The action for the next fail reboot_msg: "" # The message send to log if action is reboot the server command: "" # The command to be execute if the action is 'run command' reset_period: 86400 # The period before reset the fail count (in minutes) dependencies: # The list of service depends - Netman # An example of dependency. messenger: # This configuration allow to set on Windows service the Symfony Messenger Consumer. # Prototype - user: # The User set on the service account: ~ # the account name password: ~ # the password receivers: [] # Symfony Messenger transport consumed by the service machine: '' # the machine name for this service. displayed_name: ~ # Required, The friendly name of the service. If `thread_count` > 1, you can use `%d` to define the place of the thread number description: '' # the service description thread_count: 1 # the number of this service need to register. Use `%d` into `service_id`, `displayed_name` and `script_params` for contains the service number. delayed_start: false # If true the starting for the service is delayed limit: 0 # Reboot service after processed X messages failure-limit: 0 # Reboot service after X messages failure time-limit: 0 # Reboot service after X seconds
Define the runner
For each service, add a sub-class of Win32Service\Model\AbstractServiceRunner.
The sub-class must be configured in service with the tag win32service.runner with an alias name corresponding to the service_id.
Exemple with one thread
Extension configuration:
win32_service: windows_local_encoding: ISO-8859-1 services: - service_id: "my_service" displayed_name: "My beautiful service" #[...]
Sub-class:
class MyRunner extends \Win32Service\Model\AbstractServiceRunner {}
Service configuration :
services: MyRunner: tags: - { name: win32service.runner, alias: 'my_service'}
Exemple with many thread
Extension configuration:
win32_service: windows_local_encoding: ISO-8859-1 services: - service_id: "my_service_%d" displayed_name: "My beautiful service" thread_count: 3 #[...]
Sub-class:
class MyRunner extends \Win32Service\Model\AbstractServiceRunner {}
Service configuration :
services: MyRunner: tags: - { name: win32service.runner, alias: 'my_service_%d'}
Manage the service
Open an administrator cmd window and go to your project.
Register the service
For register all service, run this command:
php bin\console win32service:register
For register only one service (without thread number) run:
php bin\console win32service:register --service-name=my_service
For register only one service (with thread number) run:
php bin\console win32service:register --service-name=my_service_%d
Unregister the service
For unregister all service, run this command:
php bin\console win32service:unregister
For unregister only one service (without thread number) run:
php bin\console win32service:unregister --service-name=my_service
For unregister only one service (with thread number) run:
php bin\console win32service:unregister --service-name=my_service_%d
Sent action at your services
This command start all service (and all thread) defined in your project.
php bin\console win32service:action start
For sent the action for one service and all thread:
php bin\console win32service:action start --service-name=my_service_%d
For sent the action for one thread of one service (work same if the service has only one thread):
php bin\console win32service:action start --service-name=my_service_1
win32service/win32servicebundle 适用场景与选型建议
win32service/win32servicebundle 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 4.85k 次下载、GitHub Stars 达 2, 最近一次更新时间为 2019 年 02 月 19 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「symfony」 「bundle」 「service」 「windows」 「Service Manager」 「win32service」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 win32service/win32servicebundle 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 win32service/win32servicebundle 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 win32service/win32servicebundle 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
2lenet/EasyAdminPlusBundle
The bundle for easy using json-rpc api on your project
Provide a way to secure accesses to all routes of an symfony application.
DMS Meetup API Bundle, enables Meetup API clients in services
A fast and intuitive dependency injection container.
Registry service.
统计信息
- 总下载量: 4.85k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-02-19