start.php 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. /**
  3. * run with command
  4. * php start.php start
  5. */
  6. ini_set('display_errors', 'on');
  7. use Workerman\Worker;
  8. if(strpos(strtolower(PHP_OS), 'win') === 0)
  9. {
  10. exit("start.php not support windows, please use start_for_win.bat\n");
  11. }
  12. // 检查扩展
  13. if(!extension_loaded('pcntl'))
  14. {
  15. exit("Please install pcntl extension. See http://doc3.workerman.net/appendices/install-extension.html\n");
  16. }
  17. if(!extension_loaded('posix'))
  18. {
  19. exit("Please install posix extension. See http://doc3.workerman.net/appendices/install-extension.html\n");
  20. }
  21. // 标记是全局启动
  22. define('GLOBAL_START', 1);
  23. require_once __DIR__ . '/vendor/autoload.php';
  24. require_once __DIR__ . '/vendor/workerman/globaldata/src/Server.php';
  25. require_once __DIR__ . '/vendor/workerman/globaldata/src/Client.php';
  26. // 加载所有Applications/*/start.php,以便启动所有服务
  27. foreach(glob(__DIR__.'/Applications/*/start*.php') as $start_file)
  28. {
  29. require_once $start_file;
  30. }
  31. // 全局共享组件
  32. $worker = new GlobalData\Server('127.0.0.1', 2207);
  33. // 运行所有服务
  34. Worker::runAll();