{"id":3306,"date":"2018-11-03T11:44:23","date_gmt":"2018-11-03T03:44:23","guid":{"rendered":"http:\/\/www.xttblog.com\/?p=3306"},"modified":"2018-11-03T11:44:23","modified_gmt":"2018-11-03T03:44:23","slug":"nodejs-pm2-%e5%b8%b8%e7%94%a8%e5%91%bd%e4%bb%a4%e6%80%bb%e7%bb%93","status":"publish","type":"post","link":"https:\/\/www.xttblog.com\/?p=3306","title":{"rendered":"nodejs pm2 \u5e38\u7528\u547d\u4ee4\u603b\u7ed3"},"content":{"rendered":"<p>\n\tPM2\u662fnode\u8fdb\u7a0b\u7ba1\u7406\u5de5\u5177\uff0c\u53ef\u4ee5\u5229\u7528\u5b83\u6765\u7b80\u5316\u5f88\u591anode\u5e94\u7528\u7ba1\u7406\u7684\u7e41\u7410\u4efb\u52a1\uff0c\u5982\u6027\u80fd\u76d1\u63a7\u3001\u81ea\u52a8\u91cd\u542f\u3001\u8d1f\u8f7d\u5747\u8861\u7b49\uff0c\u800c\u4e14\u4f7f\u7528\u975e\u5e38\u7b80\u5355\u3002\u4f46\u662f\u5f88\u591a\u7a0b\u5e8f\u5458\u8fd8\u4e0d\u719f\u6089\u5b83\uff0c\u5c24\u5176\u662f\u5bf9\u5b83\u7684\u4e00\u4e9b\u5e38\u7528\u547d\u4ee4\u90fd\u8bb0\u4e0d\u4f4f\uff0c\u4e0d\u4f1a\u7528\u3002\n<\/p>\n<p>\n\t\u5f88\u96be\u5417\uff1f\u5176\u5b9e\u4e0d\u96be\uff01\u867d\u7136\u5b83\u547d\u4ee4\u591a\uff0c\u547d\u4ee4\u4e0d\u597d\u8bb0\uff0c\u4f46\u662f\u6211\u4eec\u53ea\u9700\u8981\u8bb0\u4f4f\u5e38\u7528\u7684\u51e0\u4e2a\u5c31\u884c\u4e86\u3002\u6ca1\u5fc5\u8981\u6b7b\u8bb0\u786c\u80cc\uff01\u4e00\u5b9a\u8981\u6d3b\u5b66\u6d3b\u7528\uff01\n<\/p>\n<p>\n\t\u4e0b\u9762\u662f\u6211\u7ecf\u5e38\u4f7f\u7528\u7684\u51e0\u4e2a\u547d\u4ee4\uff1a\n<\/p>\n<pre class=\"brush:bash;\">\r\n$ pm2 logs \u663e\u793a\u6240\u6709\u8fdb\u7a0b\u65e5\u5fd7\r\n$ pm2 stop all \u505c\u6b62\u6240\u6709\u8fdb\u7a0b\r\n$ pm2 restart all \u91cd\u542f\u6240\u6709\u8fdb\u7a0b\r\n$ pm2 reload all 0\u79d2\u505c\u673a\u91cd\u8f7d\u8fdb\u7a0b (\u7528\u4e8e NETWORKED \u8fdb\u7a0b)\r\n$ pm2 stop 0 \u505c\u6b62\u6307\u5b9a\u7684\u8fdb\u7a0b\r\n$ pm2 restart 0 \u91cd\u542f\u6307\u5b9a\u7684\u8fdb\u7a0b\r\n$ pm2 startup \u4ea7\u751f init \u811a\u672c \u4fdd\u6301\u8fdb\u7a0b\u6d3b\u7740\r\n$ pm2 web \u8fd0\u884c\u5065\u58ee\u7684 computer API endpoint (http:\/\/localhost:9615)\r\n$ pm2 delete 0 \u6740\u6b7b\u6307\u5b9a\u7684\u8fdb\u7a0b\r\n$ pm2 delete all \u6740\u6b7b\u5168\u90e8\u8fdb\u7a0b<\/pre>\n<p>\n\t\u8fd0\u884c\u8fdb\u7a0b\u7684\u51e0\u79cd\u65b9\u5f0f\uff1a\n<\/p>\n<p>\n\t$ pm2 start app.js -i max \u6839\u636e\u6709\u6548CPU\u6570\u76ee\u542f\u52a8\u6700\u5927\u8fdb\u7a0b\u6570\u76ee<br \/>\n\t$ pm2 start app.js -i 3 \u542f\u52a83\u4e2a\u8fdb\u7a0b<br \/>\n\t$ pm2 start app.js -x \u7528fork\u6a21\u5f0f\u542f\u52a8 app.js \u800c\u4e0d\u662f\u4f7f\u7528 cluster<br \/>\n\t$ pm2 start app.js -x &#8212; -a 23 \u7528fork\u6a21\u5f0f\u542f\u52a8 app.js \u5e76\u4e14\u4f20\u9012\u53c2\u6570 (-a 23)<br \/>\n\t$ pm2 start app.js &#8211;name serverone \u542f\u52a8\u4e00\u4e2a\u8fdb\u7a0b\u5e76\u628a\u5b83\u547d\u540d\u4e3a serverone<br \/>\n\t$ pm2 stop serverone \u505c\u6b62 serverone \u8fdb\u7a0b<br \/>\n\t$ pm2 start app.json \u542f\u52a8\u8fdb\u7a0b, \u5728 app.json\u91cc\u8bbe\u7f6e\u9009\u9879<br \/>\n\t$ pm2 start app.js -i max &#8212; -a 23 \u5728&#8211;\u4e4b\u540e\u7ed9 app.js \u4f20\u9012\u53c2\u6570<br \/>\n\t$ pm2 start app.js -i max -e err.log -o out.log \u542f\u52a8 \u5e76 \u751f\u6210\u4e00\u4e2a\u914d\u7f6e\u6587\u4ef6\n<\/p>\n<p>\n\t\u66f4\u591a\u8d44\u6599\u548c\u547d\u4ee4\u8bf7\u53c2\u8003\u9605\u8bfb\u5b98\u65b9\u6587\u6863\uff1a<a href=\"http:\/\/pm2.keymetrics.io\/docs\/usage\/quick-start\/#42-starts\" name=\"pm2\u5b98\u65b9\u6587\u6863\" target=\"_blank\" title=\"pm2\u5b98\u65b9\u6587\u6863\">http:\/\/pm2.keymetrics.io\/docs\/usage\/quick-start\/#42-starts<\/a><\/p>\n<!-- <audio autoplay=\"autoplay\" height=\"100\" width=\"100\" hidden=\"true\"><source src=\"https:\/\/c.coka.la\/orAvPR.mp3\" type=\"audio\/mp3\"\/><\/audio><img decoding=\"async\" src=\"https:\/\/images.weserv.nl\/?url=https:\/\/ws3.sinaimg.cn\/large\/8fa5dcfcgy1g4em3rzar5j20ib089ae0.jpg\" alt=\"\u4e1a\u4f59\u8349\u516c\u4f17\u53f7\"\/> --><p><!-- <img decoding=\"async\" src=\"https:\/\/raw.githubusercontent.com\/xmt1139057136\/xttblog\/master\/8fa5dcfcgy1g4em3rzar5j20ib089ae0.jpg\" alt=\"\u4e1a\u4f59\u8349\u516c\u4f17\u53f7\"\/>--><img decoding=\"async\" src=\"https:\/\/saas.51autoparts.cn\/api\/admin\/sys-file\/oss\/file?fileName=84db51f8561e448f9a4fda2eff0811f9.jpg\" alt=\"\u4e1a\u4f59\u8349\u516c\u4f17\u53f7\"\/><\/p><p>\u6700\u540e\uff0c\u6b22\u8fce\u5173\u6ce8\u6211\u7684\u4e2a\u4eba\u5fae\u4fe1\u516c\u4f17\u53f7\uff1a\u4e1a\u4f59\u8349\uff08yyucao\uff09\uff01<b>\u53ef\u52a0\u4f5c\u8005\u5fae\u4fe1\u53f7\uff1a<font color=\"red\">xttblog2<\/font>\u3002\u5907\u6ce8\uff1a\u201c1\u201d\uff0c\u6dfb\u52a0\u535a\u4e3b\u5fae\u4fe1\u62c9\u4f60\u8fdb\u5fae\u4fe1\u7fa4\u3002\u5907\u6ce8\u9519\u8bef\u4e0d\u4f1a\u540c\u610f\u597d\u53cb\u7533\u8bf7\u3002<\/b>\u518d\u6b21\u611f\u8c22\u60a8\u7684\u5173\u6ce8\uff01\u540e\u7eed\u6709\u7cbe\u5f69\u5185\u5bb9\u4f1a\u7b2c\u4e00\u65f6\u95f4\u53d1\u7ed9\u60a8\uff01\u539f\u521b\u6587\u7ae0\u6295\u7a3f\u8bf7\u53d1\u9001\u81f3532009913@qq.com\u90ae\u7bb1\u3002\u5546\u52a1\u5408\u4f5c\u4e5f\u53ef\u6dfb\u52a0\u4f5c\u8005\u5fae\u4fe1\u8fdb\u884c\u8054\u7cfb\uff01<\/p><p>\u672c\u6587\u539f\u6587\u51fa\u5904\uff1a<a href=\"https:\/\/www.xttblog.com\">\u4e1a\u4f59\u8349<\/a>\uff1a &raquo; <a href=\"https:\/\/www.xttblog.com\/?p=3306\">nodejs pm2 \u5e38\u7528\u547d\u4ee4\u603b\u7ed3<\/a><\/p><!-- <div class=\"bd-reward-stl\"><button id=\"bdRewardBtn\"><span><\/span><\/button><\/div> -->","protected":false},"excerpt":{"rendered":"<p>PM2\u662fnode\u8fdb\u7a0b\u7ba1\u7406\u5de5\u5177\uff0c\u53ef\u4ee5\u5229\u7528\u5b83\u6765\u7b80\u5316\u5f88\u591anode\u5e94\u7528\u7ba1\u7406\u7684\u7e41\u7410\u4efb\u52a1\uff0c\u5982\u6027\u80fd\u76d1\u63a7\u3001\u81ea\u52a8\u91cd\u542f\u3001\u8d1f\u8f7d\u5747\u8861\u7b49 [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,6],"tags":[518,1555,1737,1565,648],"class_list":["post-3306","post","type-post","status-publish","format-standard","hentry","category-html5","category-yyzt","tag-angularjs","tag-nodejs","tag-pm2","tag-svg-to-react","tag-vue"],"_links":{"self":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/3306","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3306"}],"version-history":[{"count":1,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/3306\/revisions"}],"predecessor-version":[{"id":3307,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/3306\/revisions\/3307"}],"wp:attachment":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3306"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3306"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3306"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}