forked from whcyc2002/swoole_framework
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsoa_server.php
More file actions
42 lines (37 loc) · 1.24 KB
/
soa_server.php
File metadata and controls
42 lines (37 loc) · 1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?php
define('DEBUG', 'on');
define('WEBPATH', realpath(__DIR__ . '/../'));
require dirname(__DIR__) . '/libs/lib_config.php';
//设置PID文件的存储路径
Swoole\Network\Server::setPidFile(__DIR__ . '/app_server.pid');
/**
* 显示Usage界面
* php app_server.php start|stop|reload
*/
Swoole\Network\Server::start(function ()
{
$AppSvr = new Swoole\Protocol\SOAServer;
$AppSvr->setLogger(new \Swoole\Log\EchoLog(true)); //Logger
/**
* 注册一个自定义的命名空间到SOA服务器
* 默认使用 apps/classes
*/
$AppSvr->addNameSpace('BL', __DIR__ . '/class');
Swoole\Error::$echo_html = false;
$server = Swoole\Network\Server::autoCreate('0.0.0.0', 8888);
$server->setProtocol($AppSvr);
//$server->daemonize(); //作为守护进程
$server->run(
array(
//TODO: 实际使用中必须调大进程数
'worker_num' => 1,
'max_request' => 5000,
'dispatch_mode' => 3,
'open_length_check' => 1,
'package_max_length' => $AppSvr->packet_maxlen,
'package_length_type' => 'N',
'package_body_offset' => \Swoole\Protocol\SOAServer::HEADER_SIZE,
'package_length_offset' => 0,
)
);
});