No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

worker_server.php 2.0KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | ThinkPHP [ WE CAN DO IT JUST THINK IT ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2006-2018 http://thinkphp.cn All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
  8. // +----------------------------------------------------------------------
  9. // | Author: liu21st <liu21st@gmail.com>
  10. // +----------------------------------------------------------------------
  11. // +----------------------------------------------------------------------
  12. // | Workerman设置 仅对 php think worker:server 指令有效
  13. // +----------------------------------------------------------------------
  14. return [
  15. // 扩展自身需要的配置
  16. 'protocol' => 'websocket', // 协议 支持 tcp udp unix http websocket text
  17. 'host' => '0.0.0.0', // 监听地址
  18. 'port' => 2346, // 监听端口
  19. 'socket' => '', // 完整监听地址
  20. 'context' => [], // socket 上下文选项
  21. 'worker_class' => ['app\work\controller\Push'], // 自定义Workerman服务类名 支持数组定义多个服务
  22. // 支持workerman的所有配置参数
  23. 'name' => 'thinkphp',
  24. 'count' => 4,
  25. 'daemonize' => false,
  26. 'pidFile' => '',
  27. // 支持事件回调
  28. // onWorkerStart
  29. 'onWorkerStart' => function ($worker) {
  30. },
  31. // onWorkerReload
  32. 'onWorkerReload' => function ($worker) {
  33. },
  34. // onConnect
  35. 'onConnect' => function ($connection) {
  36. },
  37. // onMessage
  38. 'onMessage' => function ($connection, $data) {
  39. $connection->send('receive success');
  40. },
  41. // onClose
  42. 'onClose' => function ($connection) {
  43. },
  44. // onError
  45. 'onError' => function ($connection, $code, $msg) {
  46. echo "error [ $code ] $msg\n";
  47. },
  48. ];