node.js - pm2 多線程cluster模式
問題描述
node中可以使用pm2進(jìn)行項目部署,可以通過參數(shù)開啟多線程,但是目前設(shè)置發(fā)現(xiàn),無論我怎么改變參數(shù),開啟的線程數(shù)都是9個,這是怎么回事那?代碼如下:
pm2.start({ script:’www’, name:’testpm2’, exec_mode:’cluster’,//開啟多線程模式 instances:10//開啟的線程數(shù)},function(err,apps){ console.log(err); pm2.disconnect();});
linux上的數(shù)據(jù):
線程數(shù)改為1時:代碼:
pm2.start({ script:’www’, name:’testpm2’, exec_mode:’cluster’,//開啟多線程模式 instances:1//開啟的線程數(shù)},function(err,apps){ console.log(err); pm2.disconnect();});
linux上的線程數(shù):
問題解答
回答1:你用ps hH p {pid} | wc -l查看到的是這個pid相關(guān)的線程,你可以用top -H -p {pid}看一下,你會發(fā)現(xiàn)出來的線程都是V8 WorkerThread 和 PM2 {version} {state}和node,這個是不會變的
你如果要看你的pm2 instance的話請使用pm2 list查看即可
相關(guān)文章:
1. mysql - msyql 判斷字段不為空 簡單方法2. docker gitlab 如何git clone?3. 關(guān)docker hub上有些鏡像的tag被標(biāo)記““This image has vulnerabilities””4. dockerfile - [docker build image失敗- npm install]5. java - yuicompressor-maven-plugin 合并可用卻不壓縮, 哪配置不對?6. docker images顯示的鏡像過多,狗眼被亮瞎了,怎么辦?7. html5 - vue 里的Elemen UI的時間怎么轉(zhuǎn)化為時間戳嗎8. linux - mysql源碼安裝遇到的問題9. javascript - Vue 自定義控件v-model雙向綁定10. angular.js使用$resource服務(wù)把數(shù)據(jù)存入mongodb的問題。
