start_businessworker.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. /**
  3. * This file is part of workerman.
  4. *
  5. * Licensed under The MIT License
  6. * For full copyright and license information, please see the MIT-LICENSE.txt
  7. * Redistributions of files must retain the above copyright notice.
  8. *
  9. * @author walkor<walkor@workerman.net>
  10. * @copyright walkor<walkor@workerman.net>
  11. * @link http://www.workerman.net/
  12. * @license http://www.opensource.org/licenses/mit-license.php MIT License
  13. */
  14. use \Workerman\Worker;
  15. use \Workerman\WebServer;
  16. use \GatewayWorker\Gateway;
  17. use \GatewayWorker\BusinessWorker;
  18. use \Workerman\Autoloader;
  19. // 自动加载类
  20. require_once __DIR__ . '/../../vendor/autoload.php';
  21. // 获取插件配置
  22. $fastchat_config = get_addon_config('fastchat');
  23. // bussinessWorker 进程
  24. $worker = new BusinessWorker();
  25. // worker名称
  26. $worker->name = 'FastChatBusinessWorker';
  27. // bussinessWorker进程数量
  28. $worker->count = $fastchat_config['worker_process_number'];
  29. // 服务注册地址
  30. $worker->registerAddress = '127.0.0.1:' . $fastchat_config['register_port'];
  31. //设置处理业务的类,此处制定Events的命名空间
  32. $worker->eventHandler = 'addons\fastchat\library\GatewayWorker\Applications\FastChat\Events';
  33. // 如果不是在根目录启动,则运行runAll方法
  34. if (!defined('GLOBAL_START')) {
  35. Worker::runAll();
  36. }