In the consolidated Swoole HTTP server and phalcon,server.php are as follows:
Registerdirs (Array ('.. /apps/controllers/', '. /apps/models/')); $loader->register (); }/** * This methods registers the services to being used by the application */protected function Registerserv Ices () {$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" = "ro") OT "," 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); The 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 ();}); # Boot server $http->start ();
No problem with browser access
The AB test is an error.
ab -n 10000 -c 1000 -rk http://phalcon.com/
Error message:
[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
Ask what is the reason for this, is onrequest there write wrong?