{"id":3310,"date":"2018-11-03T13:17:18","date_gmt":"2018-11-03T05:17:18","guid":{"rendered":"http:\/\/www.xttblog.com\/?p=3310"},"modified":"2018-11-03T13:17:18","modified_gmt":"2018-11-03T05:17:18","slug":"pm2%e5%90%af%e5%8a%a8%e6%96%87%e4%bb%b6processes-json%e9%85%8d%e7%bd%ae%e5%8f%82%e6%95%b0%e8%af%a6%e8%a7%a3","status":"publish","type":"post","link":"https:\/\/www.xttblog.com\/?p=3310","title":{"rendered":"pm2\u542f\u52a8\u6587\u4ef6processes.json\u914d\u7f6e\u53c2\u6570\u8be6\u89e3"},"content":{"rendered":"<p>\n\tpm2 \u5f88\u591a\u4eba\u4e0d\u719f\u6089\u5b83\uff0c\u5176\u5b9e\u5b83\u53ef\u4ee5\u5f88\u65b9\u4fbf\u7684\u5e2e\u52a9\u6211\u4eec\u5b9e\u73b0\u81ea\u52a8\u5316\u90e8\u7f72 nodejs \u7684\u9879\u76ee\u3002pm2 \u7ecf\u5e38\u642d\u914d&nbsp;koa\u3001mongodb\u3001nodejs\u4e00\u8d77\u4f7f\u7528\u3002\u672c\u6587\u7ed9\u5927\u5bb6\u4ecb\u7ecd\u4e00\u4e0b pm2 \u4e2d&nbsp;processes.json \u6587\u4ef6\u7684\u4e00\u4e9b\u914d\u7f6e\u53c2\u6570\u7684\u7528\u6cd5\uff0c\u5e0c\u671b\u80fd\u591f\u5e2e\u52a9\u5230\u5927\u5bb6\uff01\n<\/p>\n<p>\n\tprocesses.json \u6587\u4ef6\u6211\u4eec\u53ef\u4ee5\u81ea\u52a8\u7684\u521b\u5efa\uff0c\u4e00\u822c\u662f\u521b\u5efa\u5728\u9879\u76ee\u7684\u6839\u76ee\u5f55\u4e0b\u3002\u6bd4\u5982\u4e0b\u9762\u7684\u4e00\u4e2a\u7528\u6cd5\uff1a\n<\/p>\n<pre class=\"brush:jscript;\">\r\n{\r\n  &quot;apps&quot;: [\r\n    {\r\n      &quot;name&quot;: &quot;mywork&quot;,\r\n      &quot;cwd&quot;: &quot;\/srv\/node-app\/current&quot;,\r\n      &quot;script&quot;: &quot;bin\/www&quot;,\r\n      &quot;log_date_format&quot;: &quot;YYYY-MM-DD HH:mm Z&quot;,\r\n      &quot;error_file&quot;: &quot;\/var\/log\/node-app\/node-app.stderr.log&quot;,\r\n      &quot;out_file&quot;: &quot;log\/node-app.stdout.log&quot;,\r\n      &quot;pid_file&quot;: &quot;pids\/node-geo-api.pid&quot;,\r\n      &quot;instances&quot;: 6,\r\n      &quot;min_uptime&quot;: &quot;200s&quot;,\r\n      &quot;max_restarts&quot;: 10,\r\n      &quot;max_memory_restart&quot;: &quot;1M&quot;,\r\n      &quot;cron_restart&quot;: &quot;1 0 * * *&quot;,\r\n      &quot;watch&quot;: false,\r\n      &quot;merge_logs&quot;: true,\r\n      &quot;exec_interpreter&quot;: &quot;node&quot;,\r\n      &quot;exec_mode&quot;: &quot;fork&quot;,\r\n      &quot;autorestart&quot;: false,\r\n      &quot;vizion&quot;: false\r\n    }\r\n  ]\r\n}<\/pre>\n<p>\n\t\u770b\u5427\uff0c\u53c2\u6570\u867d\u7136\u4e0d\u591a\uff0c\u4f46\u662f\u4f60\u5f97\u61c2\u6bcf\u4e2a\u53c2\u6570\u7684\u610f\u601d\u3002\n<\/p>\n<ul>\n<li>\n\t\tapps:json\u7ed3\u6784\uff0capps\u662f\u4e00\u4e2a\u6570\u7ec4\uff0c\u6bcf\u4e00\u4e2a\u6570\u7ec4\u6210\u5458\u5c31\u662f\u5bf9\u5e94\u4e00\u4e2apm2\u4e2d\u8fd0\u884c\u7684\u5e94\u7528\n\t<\/li>\n<li>\n\t\tname:\u5e94\u7528\u7a0b\u5e8f\u540d\u79f0\n\t<\/li>\n<li>\n\t\tcwd:\u5e94\u7528\u7a0b\u5e8f\u6240\u5728\u7684\u76ee\u5f55\n\t<\/li>\n<li>\n\t\tscript:\u5e94\u7528\u7a0b\u5e8f\u7684\u811a\u672c\u8def\u5f84\n\t<\/li>\n<li>\n\t\tlog_date_format: \u65e5\u671f\u65f6\u95f4\u683c\u5f0f\u5316\n\t<\/li>\n<li>\n\t\terror_file:\u81ea\u5b9a\u4e49\u5e94\u7528\u7a0b\u5e8f\u7684\u9519\u8bef\u65e5\u5fd7\u6587\u4ef6\n\t<\/li>\n<li>\n\t\tout_file:\u81ea\u5b9a\u4e49\u5e94\u7528\u7a0b\u5e8f\u65e5\u5fd7\u6587\u4ef6\n\t<\/li>\n<li>\n\t\tpid_file:\u81ea\u5b9a\u4e49\u5e94\u7528\u7a0b\u5e8f\u7684pid\u6587\u4ef6\n\t<\/li>\n<li>\n\t\tinstances:\n\t<\/li>\n<li>\n\t\tmin_uptime:\u6700\u5c0f\u8fd0\u884c\u65f6\u95f4\uff0c\u8fd9\u91cc\u8bbe\u7f6e\u7684\u662f60s\u5373\u5982\u679c\u5e94\u7528\u7a0b\u5e8f\u572860s\u5185\u9000\u51fa\uff0cpm2\u4f1a\u8ba4\u4e3a\u7a0b\u5e8f\u5f02\u5e38\u9000\u51fa\uff0c\u6b64\u65f6\u89e6\u53d1\u91cd\u542fmax_restarts\u8bbe\u7f6e\u6570\u91cf\n\t<\/li>\n<li>\n\t\tmax_restarts:\u8bbe\u7f6e\u5e94\u7528\u7a0b\u5e8f\u5f02\u5e38\u9000\u51fa\u91cd\u542f\u7684\u6b21\u6570\uff0c\u9ed8\u8ba415\u6b21\uff08\u4ece0\u5f00\u59cb\u8ba1\u6570\uff09\n\t<\/li>\n<li>\n\t\tcron_restart:\u5b9a\u65f6\u542f\u52a8\uff0c\u89e3\u51b3\u91cd\u542f\u80fd\u89e3\u51b3\u7684\u95ee\u9898\n\t<\/li>\n<li>\n\t\twatch:\u662f\u5426\u542f\u7528\u76d1\u63a7\u6a21\u5f0f\uff0c\u9ed8\u8ba4\u662ffalse\u3002\u5982\u679c\u8bbe\u7f6e\u6210true\uff0c\u5f53\u5e94\u7528\u7a0b\u5e8f\u53d8\u52a8\u65f6\uff0cpm2\u4f1a\u81ea\u52a8\u91cd\u8f7d\u3002\u8fd9\u91cc\u4e5f\u53ef\u4ee5\u8bbe\u7f6e\u4f60\u8981\u76d1\u63a7\u7684\u6587\u4ef6\u3002\n\t<\/li>\n<li>\n\t\tmerge_logs:\n\t<\/li>\n<li>\n\t\texec_interpreter:\u5e94\u7528\u7a0b\u5e8f\u7684\u811a\u672c\u7c7b\u578b\uff0c\u8fd9\u91cc\u4f7f\u7528\u7684shell\uff0c\u9ed8\u8ba4\u662fnodejs\n\t<\/li>\n<li>\n\t\texec_mode:\u5e94\u7528\u7a0b\u5e8f\u542f\u52a8\u6a21\u5f0f\uff0c\u8fd9\u91cc\u8bbe\u7f6e\u7684\u662fcluster_mode\uff08\u96c6\u7fa4\uff09\uff0c\u9ed8\u8ba4\u662ffork\n\t<\/li>\n<li>\n\t\tautorestart:\u542f\u7528\/\u7981\u7528\u5e94\u7528\u7a0b\u5e8f\u5d29\u6e83\u6216\u9000\u51fa\u65f6\u81ea\u52a8\u91cd\u542f\n\t<\/li>\n<li>\n\t\tvizion:\u542f\u7528\/\u7981\u7528vizion\u7279\u6027(\u7248\u672c\u63a7\u5236)\n\t<\/li>\n<\/ul>\n<p>\n\t\u6709\u4e86&nbsp;processes.json \uff0c\u6211\u4eec\u5c31\u53ef\u4ee5\u8fd9\u6837\u542f\u52a8\u4e86\uff1a\n<\/p>\n<pre class=\"brush:bash;\">\r\npm2 start processes.json<\/pre>\n<p>\n\tpm2 \u975e\u5e38\u7684\u535a\u5927\u7cbe\u6df1\uff0c\u6211\u4e5f\u53ea\u662f\u4e86\u89e3\u4e86\u4e00\u4e2a\u76ae\u6bdb\u3002\u5982\u679c\u4f60\u8981\u52a0\u6df1\u7406\u89e3\u548c\u5b66\u4e60\uff0c\u5efa\u8bae\u4f60\u901a\u8bfb\u5b98\u65b9\u6587\u6863\uff1a<a href=\"http:\/\/pm2.keymetrics.io\/docs\/usage\/quick-start\/\" name=\"pm2\u5b98\u65b9\u6587\u6863\" target=\"_blank\" title=\"pm2\u5b98\u65b9\u6587\u6863\">http:\/\/pm2.keymetrics.io\/docs\/usage\/quick-start\/<\/a>\u3002<\/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=3310\">pm2\u542f\u52a8\u6587\u4ef6processes.json\u914d\u7f6e\u53c2\u6570\u8be6\u89e3<\/a><\/p><!-- <div class=\"bd-reward-stl\"><button id=\"bdRewardBtn\"><span><\/span><\/button><\/div> -->","protected":false},"excerpt":{"rendered":"<p>pm2 \u5f88\u591a\u4eba\u4e0d\u719f\u6089\u5b83\uff0c\u5176\u5b9e\u5b83\u53ef\u4ee5\u5f88\u65b9\u4fbf\u7684\u5e2e\u52a9\u6211\u4eec\u5b9e\u73b0\u81ea\u52a8\u5316\u90e8\u7f72 nodejs \u7684\u9879\u76ee\u3002pm2 \u7ecf\u5e38\u642d\u914d&#038;nb [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[1415,1555,1737,1140,648],"class_list":["post-3310","post","type-post","status-publish","format-standard","hentry","category-yyzt","tag-node-js","tag-nodejs","tag-pm2","tag-vue-video","tag-vue"],"_links":{"self":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/3310","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=3310"}],"version-history":[{"count":1,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/3310\/revisions"}],"predecessor-version":[{"id":3311,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/3310\/revisions\/3311"}],"wp:attachment":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3310"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3310"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3310"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}