Start.php 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  8. // +----------------------------------------------------------------------
  9. // | Author: CRMEB Team <admin@crmeb.com>
  10. // +----------------------------------------------------------------------
  11. namespace crmeb\utils;
  12. use think\App;
  13. /**
  14. * Start输出类
  15. * Class Json
  16. * @package crmeb\utils
  17. */
  18. class Start
  19. {
  20. public function show()
  21. {
  22. $this->opCacheClear();
  23. $context = $this->logo();
  24. $context .= $this->displayItem('php version', phpversion());
  25. $context .= $this->displayItem('swoole version', phpversion('swoole'));
  26. $context .= $this->displayItem('thinkphp version', App::VERSION);
  27. $context .= $this->displayItem('crmeb version', get_crmeb_version());
  28. //http配置
  29. $httpConf = \config("swoole.http");
  30. $context .= $this->displayItem('http enable', $httpConf["enable"]);
  31. $context .= $this->displayItem('http host', $httpConf["host"]);
  32. $context .= $this->displayItem('http port', $httpConf["port"]);
  33. $context .= $this->displayItem('http worker_num', $httpConf["worker_num"]);
  34. //websocket配置
  35. $context .= $this->displayItem('websocket enable', \config("swoole.websocket.enable"));
  36. //rpc配置
  37. $rpcConf = \config("swoole.rpc.server");
  38. $context .= $this->displayItem('rpc enable', $rpcConf["enable"]);
  39. if ($rpcConf["enable"]) {
  40. $context .= $this->displayItem('rpc host', $rpcConf["host"]);
  41. $context .= $this->displayItem('rpc port', $rpcConf["port"]);
  42. $context .= $this->displayItem('rpc worker_num', $rpcConf["worker_num"]);
  43. }
  44. //队列配置
  45. $context .= $this->displayItem('queue enable', \config("swoole.queue.enable"));
  46. //热更新配置
  47. $context .= $this->displayItem('hot_update enable', (bool)\config("swoole.hot_update.enable"));
  48. //debug配置
  49. $context .= $this->displayItem('app_debug enable', (bool)env("APP_DEBUG"));
  50. //打印信息
  51. echo $context;
  52. }
  53. private function logo()
  54. {
  55. return <<<LOGO
  56. ██████ ███████ ████ ████ ████████ ██████ ███████ ███████ ███████
  57. ██░░░░██ ░██░░░░██ ░██░██ ██░██ ░██░░░░░ ░█░░░░██ ░██░░░░██ ░██░░░░██ ██░░░░░██
  58. ██ ░░ ░██ ░██ ░██░░██ ██ ░██ ░██ ░█ ░██ ░██ ░██ ░██ ░██ ██ ░░██
  59. ░██ ░███████ ░██ ░░███ ░██ ░███████ ░██████ █████ ░███████ ░███████ ░██ ░██
  60. ░██ ░██░░░██ ░██ ░░█ ░██ ░██░░░░ ░█░░░░ ██ ░░░░░ ░██░░░░ ░██░░░██ ░██ ░██
  61. ░░██ ██ ░██ ░░██ ░██ ░ ░██ ░██ ░█ ░██ ░██ ░██ ░░██ ░░██ ██
  62. ░░██████ ░██ ░░██ ░██ ░██ ░████████ ░███████ ░██ ░██ ░░██ ░░███████
  63. ░░░░░░ ░░ ░░ ░░ ░░ ░░░░░░░░ ░░░░░░░ ░░ ░░ ░░ ░░░░░░░
  64. LOGO;
  65. }
  66. private function displayItem($name, $value)
  67. {
  68. if ($value === true) {
  69. $value = 'true';
  70. }
  71. elseif ($value === false) {
  72. $value = 'false';
  73. }
  74. elseif ($value === null) {
  75. $value = 'null';
  76. }
  77. return "\e[32m" . str_pad($name, 30, ' ', STR_PAD_RIGHT) . "\e[34m" . $value . "\e[0m \n";
  78. }
  79. private function opCacheClear()
  80. {
  81. if (function_exists('apc_clear_cache')) {
  82. apc_clear_cache();
  83. }
  84. if (function_exists('opcache_reset')) {
  85. opcache_reset();
  86. }
  87. }
  88. }