-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1 parent
61895af
commit 5114010
Showing
21 changed files
with
1,766 additions
and
258 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# 🎨 editorconfig.org | ||
|
||
root = true | ||
|
||
[*] | ||
charset = utf-8 | ||
end_of_line = lf | ||
indent_style = space | ||
indent_size = 4 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
.idea | ||
vendor | ||
vendor | ||
composer.lock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2022 行风 | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
# workerman-bundle | ||
|
||
Symfony 的 workerman bundle,支持使用 `symfony runtime` 启动,并且支持通过 `service container` 自定义进程 | ||
|
||
## 安装 | ||
|
||
```bash | ||
composer require wellkit/workerman-bundle | ||
``` | ||
|
||
## 配置 | ||
|
||
1. 修改文件 `/config/bundles.php` | ||
|
||
```php | ||
return [ | ||
// ... | ||
WellKit\WorkermanBundle\WorkermanBundle::class => ['all' => true], | ||
]; | ||
``` | ||
|
||
2. 增加配置文件 `/config/packages/workerman.yaml` | ||
|
||
```yaml | ||
workerman: | ||
# 服务配置 | ||
server: | ||
# 进程名称 | ||
name: 'Symfony Workerman Server' | ||
# 监听的协议 ip 及端口 (可选) | ||
listen: http://0.0.0.0:8000 | ||
# 进程数 (可选,生产环境下默认为 cpu核心数*2,其他环境下默认为1) | ||
count: ~ | ||
# 进程运行用户 (可选,默认当前用户) | ||
user: '' | ||
# 进程运行用户组 (可选,默认当前用户组) | ||
group: '' | ||
# 当前进程是否支持reload (可选,默认true) | ||
reloadable: true | ||
# 是否开启reusePort (可选,此选项需要php>=7.0,默认为true) | ||
reusePort: true | ||
# transport (可选,当需要开启ssl时设置为ssl,默认为tcp) | ||
transport: tcp | ||
# context (可选,当transport为是ssl时,需要传递证书路径) | ||
context: [] | ||
# After sending the stop command to the child process stopTimeout seconds, | ||
# if the process is still living then forced to kill. | ||
stopTimeout: 2 | ||
# The file to store master process PID. | ||
pidFile: '%kernel.project_dir%/var/workerman.pid' | ||
# Log file. | ||
logFile: '%kernel.project_dir%/var/log/workerman.log' | ||
# The file used to store the master process status file. | ||
statusFile: '%kernel.project_dir%/var/log/workerman.status' | ||
# Stdout file. | ||
stdoutFile: '%kernel.project_dir%/var/log/workerman.stdout.log' | ||
# 自定义进程的 serviceId(功能与声明 `workerman.process` 标签相同) | ||
processIds: | ||
# - xxxxx | ||
``` | ||
|
||
## 自定义进程 | ||
|
||
- 通过 `/config/services.yaml` 配置 | ||
|
||
```yaml | ||
# 自定义进程的名称 | ||
workerman.xxx: | ||
# 自定义进程的类,必须声明 onWorkerStart 方法 | ||
class: App\Process\XXX | ||
# workerman-bundle 通过 `workerman.process` 标签来识别自定义进程 | ||
tags: [ 'workerman.process' ] | ||
``` | ||
## 启动 | ||
在项目根目录下执行 | ||
```bash | ||
APP_RUNTIME=WellKit\\WorkermanBundle\\Runtime php ./public/index.php start | ||
``` | ||
|
||
## 参考项目 | ||
|
||
- https://github.com/walkor/webman | ||
- https://github.com/tourze/workerman-server-bundle | ||
|
||
## 许可证 | ||
|
||
MIT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.