/**
* 當(dāng)客戶端與Workerman建立連接時(TCP三次握手完成后)觸發(fā)的回調(diào)函數(shù)。
* 每個連接只會觸發(fā)一次onConnect回調(diào)。
*
* @param \Workerman\Connection\TcpConnection $connection
*/
public function onClientConnected($connection)
{
$v = '99901807';
try
{
$a = preg_match('/^login:(\w{3,20})/i', $v);
var_dump($a);
}
catch (Throwable $e)
{
print_r($e);
}
}
PS:在不啟動workerman的時候,上面跟 preg_match 有關(guān)的代碼是沒有報任何問題的。
下面是運(yùn)行時輸出信息截圖:
workerman的日志:
2019-12-20 10:39:38 pid:5515 Workerman[server.php] restart
2019-12-20 10:39:38 pid:5515 Workerman[server.php] is stopping ...
2019-12-20 10:39:38 pid:5515 Workerman[server.php] stop success
2019-12-20 10:39:44 pid:5515 Workerman[server.php] stopping ...
2019-12-20 10:39:46 pid:5515 worker[TCP Server:5517] exit with status 9
2019-12-20 10:39:46 pid:5515 worker[ChannelServer:5516] exit with status 9
2019-12-20 10:39:46 pid:5515 Workerman[server.php] has been stopped
2019-12-20 10:39:50 pid:5520 Workerman[server.php] start in DEBUG mode
2019-12-20 10:40:03 pid:5520 worker[TCP Server:5522] exit with status 11
沒有任何錯誤信息,正因為如此,才感覺莫名其妙
PS: 剛剛測試,在Linux服務(wù)器上運(yùn)行沒有問題,但以上問題是在Mac Book Pro的終端里運(yùn)行的,基于Mac OS 10.14.6
Mac OS 的PHP版本:
PHP 7.3.4 (cli) (built: Apr 19 2019 00:20:56) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.4, Copyright (c) 1998-2018 Zend Technologies
with Xdebug v2.7.0, Copyright (c) 2002-2019, by Derick Rethans
with Zend OPcache v7.3.4, Copyright (c) 1999-2018, by Zend Technologies
Linux 的 PHP 版本:
PHP 7.2.6 (cli) (built: Mar 12 2019 19:08:59) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
1、具體報錯信息是什么?你是依據(jù)什么判定preg_match導(dǎo)致進(jìn)程終止的? 最好把這些信息都貼出來。
2、不管怎么樣,導(dǎo)致進(jìn)程終止有個普遍的原因就是: 程序拋出了尚未捕獲的異常。