-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathim_server.php
46 lines (34 loc) · 1.05 KB
/
im_server.php
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
42
<?php
define('DEBUG', 'on');
// 框架需要这个常量 默认写为webroot
define('WEBPATH', __DIR__.'/webroot');
define('ROOT_PATH', __DIR__);
/**
* /vendor/autoload.php是Composer工具生成的
* shell: composer update
*/
require __DIR__.'/vendor/autoload.php';
/**
* Swoole框架自动载入器初始化
*/
Swoole\Loader::vendorInit();
/**
* 注册命名空间到自动载入器中
*/
Swoole\Loader::addNameSpace('WebIM', __DIR__.'/src/');
Swoole::getInstance()->config->setPath(__DIR__.'/configs');
//设置PID文件的存储路径
Swoole\Network\Server::setPidFile(__DIR__ . '/log/webim_server.pid');
/**
* 显示Usage界面
* php app_server.php start|stop|reload
*/
Swoole\Network\Server::start(function ()
{
$config = Swoole::getInstance()->config['webim'];
$webim = new WebIM\Server($config);
$webim->loadSetting(__DIR__ . "/swoole.ini"); //加载配置文件
$server = new Swoole\Network\Server($config['server']['host'], $config['server']['port']);
$server->setProtocol($webim);
$server->run($config['swoole']);
});