Code Monkey home page Code Monkey logo

swoft-component's Issues

restart的疑问

偶尔出现,restart项目的时候stop会卡住,然后中断指令,就会发现主进程退出了,但是子进程就像一个个孤儿一样,没人管了

各位大大,ProcessBuilder 这个类可否增加支持创建多个子进程

各位大大,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)

swoft-component/src/framework/src/Processor/EnvProcessor.php 配置后置方法定义错误

application->beforeEnv()) { CLog::warning('Stop env processor by beforeEnv return false'); return false; } $envFile = $this->application->getEnvFile(); $envFile = \alias($envFile); $path = \dirname($envFile); $env = \basename($envFile); if (!\file_exists($envFile)) { CLog::warning('Env file(%s) is not exist! skip load it', $envFile); return true; } // Load env $dotenv = new Dotenv($path, $env); $dotenv->load(); CLog::info('Env file(%s) is loaded', $envFile); return $this->application->afterEvent(); } } 配置类的后置方法afterEnv() 调用写成了 $this->application->afterEvent();

服务治理的疑问

我配了服务治理,使用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;
    }

Resolve inject type from reflection property type for php 7.4

throw new BeanException('`@Inject` must be define inejct value or `@var type` ');

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-framework

swoft-framework
这个组件尽快发个tag出来吧,我写第三方扩展,比较依赖ComposerHelper这个工具类

😄

TCP_OPEN_EOF_CHECK 为true时,RPC调用将不可用

当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调用时,消息一大,就会导致服务异常。

Request->json() 调用报错

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秒,导致停止超时。建议将服务停止时间设置为自定义,或者是将默认超时时间设定更长。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.