成人在线亚洲_国产日韩视频一区二区三区_久久久国产精品_99国内精品久久久久久久

您的位置:首頁(yè)技術(shù)文章
文章詳情頁(yè)

node.js - pm2 多線程cluster模式

瀏覽:155日期:2024-07-25 18:37:50

問題描述

node中可以使用pm2進(jìn)行項(xiàng)目部署,可以通過參數(shù)開啟多線程,但是目前設(shè)置發(fā)現(xiàn),無論我怎么改變參數(shù),開啟的線程數(shù)都是9個(gè),這是怎么回事那?代碼如下:

pm2.start({ script:’www’, name:’testpm2’, exec_mode:’cluster’,//開啟多線程模式 instances:10//開啟的線程數(shù)},function(err,apps){ console.log(err); pm2.disconnect();});

linux上的數(shù)據(jù):

node.js - pm2 多線程cluster模式

線程數(shù)改為1時(shí):代碼:

pm2.start({ script:’www’, name:’testpm2’, exec_mode:’cluster’,//開啟多線程模式 instances:1//開啟的線程數(shù)},function(err,apps){ console.log(err); pm2.disconnect();});

linux上的線程數(shù):

node.js - pm2 多線程cluster模式

問題解答

回答1:

你用ps hH p {pid} | wc -l查看到的是這個(gè)pid相關(guān)的線程,你可以用top -H -p {pid}看一下,你會(huì)發(fā)現(xiàn)出來的線程都是V8 WorkerThread 和 PM2 {version} {state}和node,這個(gè)是不會(huì)變的

你如果要看你的pm2 instance的話請(qǐng)使用pm2 list查看即可

相關(guān)文章: