swoft-cloud / swoft-component Goto Github PK
View Code? Open in Web Editor NEW📦 This is a repository of centralized management of all swoft core components
Home Page: https://www.swoft.org
License: Apache License 2.0
📦 This is a repository of centralized management of all swoft core components
Home Page: https://www.swoft.org
License: Apache License 2.0
偶尔出现,restart项目的时候stop会卡住,然后中断指令,就会发现主进程退出了,但是子进程就像一个个孤儿一样,没人管了
各位大大,ProcessBuilder 这个类可否增加支持创建多个子进程
因为我看swoft框架里面是这样的
@Process(name="getGoodProcess", coroutine=false,num=10)
,
但是目前组件不支持
以下是我修改后的
if($num > 1){
$childProcesses = [];
$pid = $process->getProcess()->pid;
while($num > 0){
$child = new SwooleProcess(function (SwooleProcess $child) use ($process,$pid,$processObject,$num,$name) {
$child = new Process($child);
$child->name($name." child process");
PhpHelper::call([$processObject, 'run'], [$child]);
});
$child->name($name." manager process");
$child->start();
App::trigger(ProcessEvent::BEFORE_PROCESS, null, $name.":child:".$child->pid);
$num --;
$childProcesses[$pid][$child->pid] = 1;
}
Process::signal(SIGCHLD, function($sig) use ($childProcesses,$pid,$process,$name) {
//必须为false,非阻塞模式
while(1){
$ret = Process::wait(false);
if($ret){
App::trigger(ProcessEvent::AFTER_PROCESS, null, $name.":child:".$ret['pid']);
unset($childProcesses[$pid][$ret['pid']]);
if(!$childProcesses[$pid]){
break;
}
}
}
if($childProcesses[$pid]){
foreach ($childProcesses[$pid] as $cid=>$v){
App::trigger(ProcessEvent::AFTER_PROCESS, null, $name.":child:".$cid);
}
unset($childProcesses[$pid]);
}
$process->exit();
});
}else{
PhpHelper::call([$processObject, 'run'], [$process]);
}
Originally posted by @liida in #153 (comment)
$value 没有转义处理,当 $value 包含 '
时会报错
之前测试遇到的redis->multi()->incr('xxx')->del('yyy')->exec() 丢失了配置中的前缀redis_
Channel->stats()
我配了服务治理,使用consul
但是我调用rpc服务的时候,目标地址似乎没办法从consul上获取?
是我用的有啥问题么?这部分文档上也没有说的太明白。
我看源码这里,似乎RPC客户端获取服务地址时,只在pool获取
public function createConnection()
{
$client = new Client(SWOOLE_SOCK_TCP | SWOOLE_KEEP);
$address = $this->pool->getConnectionAddress();
$timeout = $this->pool->getTimeout();
list($host, $port) = explode(':', $address);
if (!$client->connect($host, $port, $timeout)) {
$error = sprintf('Service connect fail errorCode=%s host=%s port=%s', $client->errCode, $host, $port);
App::error($error);
throw new RpcClientException($error);
}
$this->connection = $client;
}
public function recv(): string
{
return fread($this->connection, 1024);
}
这个方法1024目前是写死的,希望能够加到配置中
https://www.php.net/manual/reflectionproperty.gettype.php
For example:
/**
* @Inject()
*/
private SomeInterface $someProperty;
Instead of
/**
* @Inject(SomeInterface::class)
*/
private SomeInterface $someProperty;
Or more ugly
/**
* @var SomeInterface
*/
private SomeInterface $someProperty;
swoft/task component 集成 Swoole 进程池
swoft-framework
这个组件尽快发个tag出来吧,我写第三方扩展,比较依赖ComposerHelper这个工具类
😄
当TCP_OPEN_EOF_CHECK=true时,因为
/**
* @param string $data
*
* @return bool
*/
public function send(string $data): bool
{
$result = $this->connection->send($data);
$this->recv = false;
return $result;
}
发送数据时,不是以\r\n结尾,所有onReceive就会一直阻塞等待。导致客户端调用失败。
这里希望尽快修改一下,要不然RPC调用时,消息一大,就会导致服务异常。
如果$this->connection->headers为null, 会报Warning。
swoft-component/src/server/src/Server.php
Line 492 in b701125
Swoole\Runtime::enableCoroutine(SWOOLE_HOOK_ALL | SWOOLE_HOOK_CURL);
https://www.swoole.co.uk/docs/modules/swoole-runtime-flags
PHP Warning: stripos() expects parameter 1 to be string, array given in /home/www-data/Project/swoft/vendor/swoft/http-message/src/Server/Concerns/InteractsWithInput.php on line 140
json方法中 stripos 调用 InteractsWithInput->getHeader 返回的数据,此方法返回数组
在生产环境运行,服务重启时偶尔不成功。经过初步排查定位为服务在停止时超时导致失败。 框架默认将超时时间设置为60秒。目前业务中有定时器任务,其执行时间超过60秒,导致停止超时。建议将服务停止时间设置为自定义,或者是将默认超时时间设定更长。
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.