在整合swoole http server和phalcon,server.php如下:
registerdirs(array( '../apps/controllers/', '../apps/models/' )); $loader->register(); } /** * this methods registers the services to be used by the application */ protected function registerservices() { $di = new di(); //registering a router $di->set('router', function(){ return new router(); }); //registering a dispatcher $di->set('dispatcher', function(){ return new dispatcher(); }); //registering a http\response $di->set('response', function(){ return new response(); }); //registering a http\request $di->set('request', function(){ return new request(); }); //registering the view component $di->set('view', function(){ $view = new view(); $view->setviewsdir('../apps/views/'); return $view; }); $di->set('db', function(){ return new database(array( host => localhost, username => root, password => , dbname => invo )); }); //registering the models-metadata $di->set('modelsmetadata', function(){ return new memorymetadata(); }); //registering the models manager $di->set('modelsmanager', function(){ return new modelsmanager(); }); $this->setdi($di); } public function main() { $this->registerservices(); $this->registerautoloaders(); }}$application = null;$http = new swoole_http_server(0.0.0.0, 9501);$http->on('request', function ($request, $response) { try { $_get = $_post = $_cookie = $_request = []; if (!empty($request->get)) { $_get = $request->get; $_request += $_get; } if (!empty($request->post)) { $_post = $request->post; $_request += $_post; } if (!empty($request->cookie)) { $_cookie = $request->cookie; } global $application; $html = $application->handle($request->server['request_uri'])->getcontent(); $response->end($html); } catch (\exception $e){ print_r($e); echo $e->getmessage(); }});$http->on('workerstart', function($server, $workerid) { global $application; $application = new application(); $application->main();});# 启动服务器$http->start();
浏览器访问没什么问题
做ab测试就报错了
ab -n 10000 -c 1000 -rk http://phalcon.com/
错误信息:
[root@localhost public]# [2016-08-25 17:12:45 *12502.0] error zm_deactivate_swoole (error 103): fatal error: allowed memory size of 268435456 bytes exhausted (tried to allocate 16384 bytes) in /srv/www/single/public/server.php on line 126.[2016-08-25 17:12:45 $12497.0] warning swmanager_check_exit_status: worker#0 abnormal exit, status=255, signal=0
请教这是什么原因导致的,是onrequest那里写的不对吗?