Skip to content

Commit

Permalink
第一次提交,完成主要功能
Browse files Browse the repository at this point in the history
niqingyang committed Sep 15, 2022

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 61895af commit 5114010
Showing 21 changed files with 1,766 additions and 258 deletions.
11 changes: 11 additions & 0 deletions .editorconfig
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
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
.idea
vendor
vendor
composer.lock
21 changes: 21 additions & 0 deletions LICENSE
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.
90 changes: 90 additions & 0 deletions README.md
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
25 changes: 18 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
{
"name": "wellkit/workerman-runtime",
"type": "library",
"name": "wellkit/workerman-bundle",
"type": "symfony-bundle",
"license": "MIT",
"description": "symfony workerman runtime",
"description": "symfony workerman bundle",
"keywords": ["workerman", "symfony", "runtime", "php-runtime"],
"homepage": "https://github.com/niqingyang/workerman-runtime",
"minimum-stability": "stable",
"prefer-stable": true,
"authors": [
{
"name": "niqingyang",
@@ -14,21 +15,31 @@
],
"require": {
"symfony/runtime": "^6.0",
"symfony/http-kernel": "^6.0",
"symfony/http-kernel": "^6.1",
"workerman/workerman": "^4.0",
"php": ">=8.0.2",
"chubbyphp/chubbyphp-workerman-request-handler": "^2.0",
"nyholm/psr7": "^1.5",
"symfony/psr-http-message-bridge": "^2.1"
"symfony/psr-http-message-bridge": "^2.1",
"league/mime-type-detection": "^1.11",
"workerman/psr7": "^1.4",
"symfony/config": "^6.1",
"symfony/dependency-injection": "^6.1",
"symfony/yaml": "^6.1"
},
"autoload": {
"psr-4": {
"WellKit\\WorkermanRuntime\\": "src/"
"WellKit\\WorkermanBundle\\": "src/"
}
},
"config": {
"sort-packages": true,
"allow-plugins": {
"symfony/runtime": true
}
},
"extra": {
"branch-alias": {
"dev-master": "0.0.2-dev"
}
}
}
Loading

0 comments on commit 5114010

Please sign in to comment.