1hyperf生命週期

2021-10-10 22:17:40 字數 2570 閱讀 3918

hyperf 的命令管理預設由

symfony/console
提供支援 (如果您希望更換該元件您也可以通過改變 skeleton 的入口檔案更換成您希望使用的元件), 在執行

php bin/hyperf.php start
後,將由

hyperf\server\command\startserver
命令類接管,並根據配置檔案

config/autoload/server.php
內定義的 server 逐個啟動

hyperf\server\command\startserver.php
public function __construct(containerinte***ce $container)

這裡是定義start的地方

protected function execute(inputinte***ce $input, outputinte***ce $output)

$serve***ctory->configure($serverconfig);

runtime::enablecoroutine(true, swoole_hook_flags());

$serve***ctory->start();

return 0;

}

這裡執行的時候可以看到 $output的內容

object(symfony\component\console\output\consoleoutput)#77168 (5) 

["background":"symfony\component\console\formatter\outputformatterstyle":private]=>

array(2)

["href":"symfony\component\console\formatter\outputformatterstyle":private]=>

null

["options":"symfony\component\console\formatter\outputformatterstyle":private]=>

array(0)

["handleshrefgracefully":"symfony\component\console\formatter\outputformatterstyle":private]=>

null

}["info"]=>

object(symfony\component\console\formatter\outputformatterstyle)#77102 (5)

["background":"symfony\component\console\formatter\outputformatterstyle":private]=>

null

["href":"symfony\component\console\formatter\outputformatterstyle":private]=>

null

["options":"symfony\component\console\formatter\outputformatterstyle":private]=>

array(0)

["handleshrefgracefully":"symfony\component\console\formatter\outputformatterstyle":private]=>

null

}["comment"]=>

object(symfony\component\console\formatter\outputformatterstyle)#77462 (5)

["background":"symfony\component\console\formatter\outputformatterstyle":private]=>

null

["href":"symfony\component\console\formatter\outputformatterstyle":private]=>

null

["options":"symfony\component\console\formatter\outputformatterstyle":private]=>

array(0)

["handleshrefgracefully":"symfony\component\console\formatter\outputformatterstyle":private]=>

null

}...

並且要求至少啟動乙個server,由配置檔案 config/autoload/server.php 定義的server逐個啟動,例如主程式啟動使用9501,websocket啟動使用9502,grpc啟動使用9503...這樣服務依次啟動,互不影響,方便使用

而且這個操作預設是在入口檔案config/container.php裡面實現了的,也就是上文講到的重點

React 生命週期 生命週期方法

生命週期 掛載 更新 解除安裝 元件被建立 執行初始化 並被掛載到dom中,完成元件的第一次渲染 constructor props getderivedstatefromprops props,state render componentdidmount 元件被建立時會首先呼叫元件的構造方法,接受...

actived生命週期 Vuejs 生命週期

每個 vue 例項在被建立時都要經過一系列的初始化過程。如需要設定資料監聽 編譯模板 將例項掛載到 dom 並在資料變化時更新 dom 等。同時在這個過程中也會執行一些叫做生命週期鉤子的函式,這給了使用者在不同階段新增自己的 的機會。乙個 vue 例項 我們建立乙個 vue 例項,並在每個階段驗證 ...

1 生命週期

not running 非執行狀態 not running inactive active background suspended inactive 前台非活動狀態 active 前台活動狀態 background 後台狀態 suspended 掛起狀態 not running inactive ...