{"action":"created","issue":{"url":"https://api.github.com/repos/swoole/swoole-src/issues/2859","repository_url":"https://api.github.com/repos/swoole/swoole-src","labels_url":"https://api.github.com/repos/swoole/swoole-src/issues/2859/labels{/name}","comments_url":"https://api.github.com/repos/swoole/swoole-src/issues/2859/comments","events_url":"https://api.github.com/repos/swoole/swoole-src/issues/2859/events","html_url":"https://github.com/swoole/swoole-src/issues/2859","id":499256239,"node_id":"MDU6SXNzdWU0OTkyNTYyMzk=","number":2859,"title":"demon running problem , NOTICE\tphp_swoole_server_rshutdown (ERRNO 9003): worker process is terminated by exit()/die()","user":{"login":"ermya","id":17262112,"node_id":"MDQ6VXNlcjE3MjYyMTEy","avatar_url":"https://avatars3.githubusercontent.com/u/17262112?v=4","gravatar_id":"","url":"https://api.github.com/users/ermya","html_url":"https://github.com/ermya","followers_url":"https://api.github.com/users/ermya/followers","following_url":"https://api.github.com/users/ermya/following{/other_user}","gists_url":"https://api.github.com/users/ermya/gists{/gist_id}","starred_url":"https://api.github.com/users/ermya/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ermya/subscriptions","organizations_url":"https://api.github.com/users/ermya/orgs","repos_url":"https://api.github.com/users/ermya/repos","events_url":"https://api.github.com/users/ermya/events{/privacy}","received_events_url":"https://api.github.com/users/ermya/received_events","type":"User","site_admin":false},"labels":[{"id":9887903,"node_id":"MDU6TGFiZWw5ODg3OTAz","url":"https://api.github.com/repos/swoole/swoole-src/labels/question","name":"question","color":"cc317c","default":true}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2019-09-27T06:17:28Z","updated_at":"2019-09-27T07:38:28Z","closed_at":"2019-09-27T07:31:09Z","author_association":"NONE","body":"Please answer these questions before submitting your issue. Thanks!\r\n\r\n1. What did you do? If possible, provide a simple script for reproducing the error.\r\ni just use this simple TCP proxy example was wrote by matyhtf: \r\nhttps://github.com/swoole/proxy-server/blob/master/tcp-proxy.php\r\n\r\ncodes are here \r\n```\r\n<?php\r\nclass ProxyServer\r\n{\r\n    protected $frontends;\r\n    protected $backends;\r\n    /**\r\n     * @var swoole_server\r\n     */\r\n    protected $serv;\r\n    protected $index = 0;\r\n    protected $mode = SWOOLE_BASE;\r\n    protected $backendServer = array('host' => '127.0.0.1', 'port' => '80');\r\n    function run()\r\n    {\r\n        $serv = new swoole_server(\"127.0.0.1\", 9509, $this->mode);\r\n        $serv->set(array(\r\n            'worker_num' => 8, //worker process num\r\n            //'backlog' => 128, //listen backlog\r\n            //'open_tcp_keepalive' => 1,\r\n            //'log_file' => '/tmp/swoole.log', //swoole error log\r\n        ));\r\n        $serv->on('WorkerStart', array($this, 'onStart'));\r\n        $serv->on('Receive', array($this, 'onReceive'));\r\n        $serv->on('Close', array($this, 'onClose'));\r\n        $serv->on('WorkerStop', array($this, 'onShutdown'));\r\n        $serv->start();\r\n    }\r\n    function onStart($serv)\r\n    {\r\n        $this->serv = $serv;\r\n        echo \"Server: start.Swoole version is [\" . SWOOLE_VERSION . \"]\\n\";\r\n    }\r\n    function onShutdown($serv)\r\n    {\r\n        echo \"Server: onShutdown\\n\";\r\n    }\r\n    function onClose($serv, $fd, $from_id)\r\n    {\r\n        //清理掉后端连接\r\n        if (isset($this->frontends[$fd]))\r\n        {\r\n            $backend_socket = $this->frontends[$fd];\r\n            $backend_socket->closing = true;\r\n            $backend_socket->close();\r\n            unset($this->backends[$backend_socket->sock]);\r\n            unset($this->frontends[$fd]);\r\n        }\r\n        echo \"onClose: frontend[$fd]\\n\";\r\n    }\r\n    function onReceive($serv, $fd, $from_id, $data)\r\n    {\r\n        //尚未建立连接\r\n        if (!isset($this->frontends[$fd]))\r\n        {\r\n            //连接到后台服务器\r\n            $socket = new swoole_client(SWOOLE_SOCK_TCP, SWOOLE_SOCK_ASYNC);\r\n            $socket->closing = false;\r\n            $socket->on('connect', function (swoole_client $socket) use ($data)\r\n            {\r\n                $socket->send($data);\r\n            });\r\n            $socket->on('error', function (swoole_client $socket) use ($fd)\r\n            {\r\n                echo \"ERROR: connect to backend server failed\\n\";\r\n                $this->serv->send($fd, \"backend server not connected. please try reconnect.\");\r\n                $this->serv->close($fd);\r\n            });\r\n            $socket->on('close', function (swoole_client $socket) use ($fd)\r\n            {\r\n                echo \"onClose: backend[{$socket->sock}]\\n\";\r\n                unset($this->backends[$socket->sock]);\r\n                unset($this->frontends[$fd]);\r\n                if (!$socket->closing)\r\n                {\r\n                    $this->serv->close($fd);\r\n                }\r\n            });\r\n            $socket->on('receive', function (swoole_client $socket, $_data) use ($fd)\r\n            {\r\n                //PHP-5.4以下版本可能不支持此写法，匿名函数不能调用$this\r\n                //可以修改为类静态变量\r\n                $this->serv->send($fd, $_data);\r\n            });\r\n            if ($socket->connect($this->backendServer['host'], $this->backendServer['port']))\r\n            {\r\n                $this->backends[$socket->sock] = $fd;\r\n                $this->frontends[$fd] = $socket;\r\n            }\r\n            else\r\n            {\r\n                echo \"ERROR: cannot connect to backend server.\\n\";\r\n                $this->serv->send($fd, \"backend server not connected. please try reconnect.\");\r\n                $this->serv->close($fd);\r\n            }\r\n        }\r\n        //已经有连接，可以直接发送数据\r\n        else\r\n        {\r\n            /**\r\n             * @var $socket swoole_client\r\n             */\r\n            $socket = $this->frontends[$fd];\r\n            $socket->send($data);\r\n        }\r\n    }\r\n}\r\n$serv = new ProxyServer();\r\n$serv->run();\r\n```\r\n\r\nwithout any customization\r\n\r\n2. What did you expect to see?\r\n\r\nnothing, just simply working as proxy in daemon\r\n\r\n3. What did you see instead?\r\n\r\nis working fine when is run by root user on terminal , but when i run it as daemon in background like this:\r\nphp tco.php & and then close terminal\r\nor use demonize property in code then close terminal \r\nthe program will goes in background for working , it works perfectly but when i send 200 user connection  for test connection , after successful connection then  i kill all of them from backend server and start test connection again , face me a lot of this error in swoole error log \r\n\r\n[2019-09-27 08:27:19 *5115.1]\tNOTICE\tphp_swoole_server_rshutdown (ERRNO 9003): worker process is terminated by exit()/die()\r\n[2019-09-27 08:27:19 *5834.1]\r\n \r\nand cpu usage will be 100% , when i check in htop i saw child process of swoole will close create then close and create too fast\r\n\r\ni try this test a lot of times with a lotf of customization and without customization but every time is same  , when is run from terminal with putty , everything works perfect and fast, when i try as daemon the problem will be happened!\r\n\r\n4. What version of Swoole are you using (show your `php --ri swoole`)?\r\n\r\n#swoole\r\n\r\nSwoole => enabled\r\nAuthor => Swoole Team <team@swoole.com>\r\nVersion => 4.4.6\r\nBuilt => Sep 23 2019 07:50:18\r\ncoroutine => enabled\r\nepoll => enabled\r\neventfd => enabled\r\nsignalfd => enabled\r\ncpu_affinity => enabled\r\nspinlock => enabled\r\nrwlock => enabled\r\nhttp2 => enabled\r\npcre => enabled\r\nzlib => enabled\r\nmutex_timedlock => enabled\r\npthread_barrier => enabled\r\nfutex => enabled\r\nasync_redis => enabled\r\n\r\nDirective => Local Value => Master Value\r\nswoole.enable_coroutine => On => On\r\nswoole.enable_library => On => On\r\nswoole.enable_preemptive_scheduler => Off => Off\r\nswoole.display_errors => On => On\r\nswoole.use_shortname => On => On\r\nswoole.unixsock_buffer_size => 8388608 => 8388608\r\n\r\n\r\n5. What is your machine environment used (including version of kernel & php & gcc) ?\r\n#uname -a \r\nLinux static.18.37 3.10.0-957.12.2.el7.x86_64 #1 SMP Tue May 14 21:24:32 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux\r\n\r\n# cat /etc/os-release\r\nNAME=\"CentOS Linux\"\r\nVERSION=\"7 (Core)\"\r\nID=\"centos\"\r\nID_LIKE=\"rhel fedora\"\r\nVERSION_ID=\"7\"\r\nPRETTY_NAME=\"CentOS Linux 7 (Core)\"\r\nANSI_COLOR=\"0;31\"\r\nCPE_NAME=\"cpe:/o:centos:centos:7\"\r\nHOME_URL=\"https://www.centos.org/\"\r\nBUG_REPORT_URL=\"https://bugs.centos.org/\"\r\n\r\nCENTOS_MANTISBT_PROJECT=\"CentOS-7\"\r\nCENTOS_MANTISBT_PROJECT_VERSION=\"7\"\r\nREDHAT_SUPPORT_PRODUCT=\"centos\"\r\nREDHAT_SUPPORT_PRODUCT_VERSION=\"7\"\r\n\r\n\r\n# php -v\r\nPHP 7.1.32 (cli) (built: Aug 28 2019 13:15:08) ( NTS )\r\nCopyright (c) 1997-2018 The PHP Group\r\nZend Engine v3.1.0, Copyright (c) 1998-2018 Zend Technologies\r\n    with Zend OPcache v7.1.32, Copyright (c) 1999-2018, by Zend Technologies\r\n\r\n#gcc -v\r\nUsing built-in specs.\r\nCOLLECT_GCC=gcc\r\nCOLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/4.8.5/lto-wrapper\r\nTarget: x86_64-redhat-linux\r\nConfigured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-linker-hash-style=gnu --enable-languages=c,c++,objc,obj-c++,java,fortran,ada,go,lto --enable-plugin --enable-initfini-array --disable-libgcj --with-isl=/builddir/build/BUILD/gcc-4.8.5-20150702/obj-x86_64-redhat-linux/isl-install --with-cloog=/builddir/build/BUILD/gcc-4.8.5-20150702/obj-x86_64-redhat-linux/cloog-install --enable-gnu-indirect-function --with-tune=generic --with-arch_32=x86-64 --build=x86_64-redhat-linux\r\nThread model: posix\r\ngcc version 4.8.5 20150623 (Red Hat 4.8.5-36) (GCC)\r\n\r\ncpu info : Intel(R) Xeon(R) CPU E5-1650 v2 @ 3.50GHz  \r\n64G memory \r\n32G swp\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/swoole/swoole-src/issues/comments/535828856","html_url":"https://github.com/swoole/swoole-src/issues/2859#issuecomment-535828856","issue_url":"https://api.github.com/repos/swoole/swoole-src/issues/2859","id":535828856,"node_id":"MDEyOklzc3VlQ29tbWVudDUzNTgyODg1Ng==","user":{"login":"ermya","id":17262112,"node_id":"MDQ6VXNlcjE3MjYyMTEy","avatar_url":"https://avatars3.githubusercontent.com/u/17262112?v=4","gravatar_id":"","url":"https://api.github.com/users/ermya","html_url":"https://github.com/ermya","followers_url":"https://api.github.com/users/ermya/followers","following_url":"https://api.github.com/users/ermya/following{/other_user}","gists_url":"https://api.github.com/users/ermya/gists{/gist_id}","starred_url":"https://api.github.com/users/ermya/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ermya/subscriptions","organizations_url":"https://api.github.com/users/ermya/orgs","repos_url":"https://api.github.com/users/ermya/repos","events_url":"https://api.github.com/users/ermya/events{/privacy}","received_events_url":"https://api.github.com/users/ermya/received_events","type":"User","site_admin":false},"created_at":"2019-09-27T07:38:28Z","updated_at":"2019-09-27T07:38:28Z","author_association":"NONE","body":"@twose thank you for your answer , i just copy and past the php code what i used ! did you see any exit or die in the code ?"}}
{"actor":{"display_login":"ermya"}}