forked from whcyc2002/swoole_framework
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhttp_server.php
More file actions
23 lines (20 loc) · 865 Bytes
/
http_server.php
File metadata and controls
23 lines (20 loc) · 865 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<?php
define('DEBUG', 'on');
require __DIR__ . '/../libs/lib_config.php';
//require __DIR__'/phar://swoole.phar';
Swoole\Config::$debug = false;
$AppSvr = new Swoole\Network\Protocol\HttpServer();
$AppSvr->loadSetting(__DIR__.'/swoole.ini'); //加载配置文件
$AppSvr->setDocumentRoot(__DIR__.'/webroot');
$AppSvr->setLogger(new \Swoole\Log\EchoLog(true)); //Logger
Swoole\Error::$echo_html = false;
/**
* 如果你没有安装swoole扩展,这里还可选择
* BlockTCP 阻塞的TCP,支持windows平台
* SelectTCP 使用select做事件循环,支持windows平台
* EventTCP 使用libevent,需要安装libevent扩展
*/
$server = new \Swoole\Network\Server('0.0.0.0', 8888);
$server->setProtocol($AppSvr);
//$server->daemonize(); //作为守护进程
$server->run(array('worker_num' => 8, 'max_request' => 5000, 'log_file' => '/tmp/swoole.log'));