Start.php 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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 qiniu\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. //http配置
  28. $httpConf = \config("swoole.http");
  29. $context .= $this->displayItem('http enable', $httpConf["enable"]);
  30. $context .= $this->displayItem('http host', $httpConf["host"]);
  31. $context .= $this->displayItem('http port', $httpConf["port"]);
  32. $context .= $this->displayItem('http worker_num', $httpConf["worker_num"]);
  33. //websocket配置
  34. $context .= $this->displayItem('websocket enable', \config("swoole.websocket.enable"));
  35. //rpc配置
  36. $rpcConf = \config("swoole.rpc.server");
  37. $context .= $this->displayItem('rpc enable', $rpcConf["enable"]);
  38. if ($rpcConf["enable"]) {
  39. $context .= $this->displayItem('rpc host', $rpcConf["host"]);
  40. $context .= $this->displayItem('rpc port', $rpcConf["port"]);
  41. $context .= $this->displayItem('rpc worker_num', $rpcConf["worker_num"]);
  42. }
  43. //队列配置
  44. $context .= $this->displayItem('queue enable', \config("swoole.queue.enable"));
  45. //热更新配置
  46. $context .= $this->displayItem('hot_update enable', (bool)\config("swoole.hot_update.enable"));
  47. //debug配置
  48. $context .= $this->displayItem('app_debug enable', (bool)env("APP_DEBUG"));
  49. //打印信息
  50. echo $context;
  51. }
  52. private function logo()
  53. {
  54. return <<<LOGO
  55. ░░░░░░ ░░░░░░ ░░░░░ ░░░░░░ ░░░░░░ ░░░░░░ ░░░░░░
  56. ░██████ ░░ ██████ █████░░██████ ██████ ██████ ██████
  57. ██░ ██░ ██░ ████░░ ██░ ██░ ██░ ██░
  58. ██░ ░░██░ ██░ ██░██░░██░ ██░ ██░ ██░
  59. ██░ ██ ██░ ██░ ██░ ██░██░ ██░ ██░ ██░
  60. ██ ░░░░███░░ ░██░░░ ██░░░████░░░ ░██░░░ ██ ░░░░░██
  61. ██████ ██ ██████ ██████ █████ ██████ ██████\n
  62. LOGO;
  63. }
  64. private function displayItem($name, $value)
  65. {
  66. if ($value === true) {
  67. $value = 'true';
  68. }
  69. elseif ($value === false) {
  70. $value = 'false';
  71. }
  72. elseif ($value === null) {
  73. $value = 'null';
  74. }
  75. return "\e[32m" . str_pad($name, 30, ' ', STR_PAD_RIGHT) . "\e[34m" . $value . "\e[0m \n";
  76. }
  77. private function opCacheClear()
  78. {
  79. if (function_exists('apc_clear_cache')) {
  80. apc_clear_cache();
  81. }
  82. if (function_exists('opcache_reset')) {
  83. opcache_reset();
  84. }
  85. }
  86. }