{"id":295482,"date":"2019-12-17T16:16:58","date_gmt":"2019-12-17T16:16:58","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=295482"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=295482","title":{"rendered":"PM2: \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u043c \u043a \u0432\u043e\u043f\u0440\u043e\u0441\u0443 \u043f\u0440\u043e\u0446\u0435\u0441\u0441-\u043c\u0435\u043d\u0435\u0434\u0436\u043c\u0435\u043d\u0442\u0430 \u0441 \u0443\u043c\u043e\u043c"},"content":{"rendered":"\n<div class=\"post__text post__text-html js-mediator-article\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/480670\/\">\u0411\u0443\u043a\u0432\u0430\u043b\u044c\u043d\u043e \u043f\u0430\u0440\u0443 \u0447\u0430\u0441\u043e\u0432 \u043d\u0430\u0437\u0430\u0434 \u0443 \u043c\u0435\u043d\u044f \u0437\u0430\u0432\u044f\u0437\u0430\u043b\u0441\u044f \u0441\u043f\u043e\u0440 \u043d\u0430 \u0442\u0435\u043c\u0443 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e Node.JS \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u0430\u044f \u0434\u043b\u044f \u043a\u0440\u0443\u043f\u043d\u044b\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u0432 \u0438 \u0435\u0439 \u0441\u0442\u043e\u0438\u0442 \u043f\u0440\u0435\u0434\u043f\u043e\u0447\u0435\u0441\u0442\u044c Golang, Rust, PHP, etc. \u041e\u0441\u043d\u043e\u0432\u043d\u044b\u043c \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u043c \u043f\u0440\u043e\u0442\u0438\u0432\u043e\u043f\u043e\u043b\u043e\u0436\u043d\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u044b \u0432 \u044d\u0442\u043e\u043c \u0441\u043f\u043e\u0440\u0435 \u0431\u044b\u043b \u0444\u0430\u043a\u0442 \u043e\u0434\u043d\u043e\u043f\u043e\u0442\u043e\u0447\u043d\u043e\u0441\u0442\u0438 JavaScript. \u042f\u043a\u043e\u0431\u044b \u043f\u0440\u0438 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u043e \u0443\u043f\u0440\u0451\u0442\u0441\u044f \u0432 \u044d\u0442\u0443 \u043e\u0434\u043d\u043e\u043f\u043e\u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c \u0438 \u043d\u0438\u0447\u0435\u0433\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0443\u0436\u0435 \u043d\u0435\u043b\u044c\u0437\u044f \u2014 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0435\u0440\u0435\u043f\u0438\u0441\u0430\u0442\u044c \u043d\u0430 \u043a\u0430\u043a\u043e\u043c-\u0442\u043e \u0434\u0440\u0443\u0433\u043e\u043c \u044f\u0437\u044b\u043a\u0435. \u041e\u0434\u043d\u0430\u043a\u043e \u0434\u0435\u043b\u0430 \u0441 \u044d\u0442\u0438\u043c \u0432 NodeJS \u043e\u0431\u0441\u0442\u043e\u044f\u0442 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043b\u0443\u0447\u0448\u0435, \u0447\u0435\u043c \u043a\u0430\u0436\u0435\u0442\u0441\u044f \u043d\u0430 \u043f\u0435\u0440\u0432\u044b\u0439 \u0432\u0437\u0433\u043b\u044f\u0434. \u041f\u0435\u0440\u0435\u0434 \u0442\u0435\u043c, \u043a\u0430\u043a \u043c\u044b \u0443\u0433\u043b\u0443\u0431\u0438\u043c\u0441\u044f \u0432 \u044d\u0442\u0443 \u0442\u0435\u043c\u0443 \u0445\u043e\u0447\u0443 \u0437\u0430\u044f\u0432\u0438\u0442\u044c, \u0447\u0442\u043e \u0443\u0432\u0430\u0436\u0430\u044e \u043f\u0440\u0430\u0432\u043e \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0442\u043e\u0442 \u044f\u0437\u044b\u043a \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u0438\u0448\u0451\u043b\u0441\u044f \u0435\u043c\u0443 \u043f\u043e \u0434\u0443\u0448\u0435 \u0438 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u043d \u0441\u0447\u0438\u0442\u0430\u0435\u0442 \u043f\u0440\u0435\u0434\u043f\u043e\u0447\u0442\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u043c \u0432 \u0442\u043e\u0439 \u0438\u043b\u0438 \u0438\u043d\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0435.<\/p>\n<p>  \u0421\u0434\u0435\u043b\u0430\u0432 \u043f\u043e\u0438\u0441\u043a \u043f\u043e \u043a\u043b\u044e\u0447\u0435\u0432\u043e\u043c\u0443 \u0441\u043b\u043e\u0432\u0443 \u00abPM2\u00bb \u043d\u0430 \u0425\u0430\u0431\u0440\u0435 \u044f \u043d\u0435 \u043d\u0430\u0448\u0451\u043b \u043d\u0438 \u043e\u0434\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438, \u043f\u043e\u0441\u0432\u044f\u0449\u0451\u043d\u043d\u043e\u0439 \u044d\u0442\u043e\u043c\u0443 process-\u043c\u0435\u043d\u0435\u0434\u0436\u0435\u0440\u0443. \u041b\u0438\u0448\u044c \u043e\u0434\u0438\u043d\u043e\u0447\u043d\u044b\u0435 \u0443\u043f\u043e\u043c\u0438\u043d\u0430\u043d\u0438\u044f \u0432 \u0441\u0442\u0430\u0442\u044c\u044f\u0445 \u0434\u0440\u0443\u0433\u0438\u0445 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439. \u042f \u0437\u0430\u0433\u043e\u0440\u0435\u043b\u0441\u044f (\u0441\u0438\u043b\u044c\u043d\u043e \u0441\u043a\u0430\u0437\u0430\u043d\u043e) \u0438\u0434\u0435\u0435\u0439 \u043d\u0430\u0432\u0435\u0440\u0441\u0442\u0430\u0442\u044c \u0443\u043f\u0443\u0449\u0435\u043d\u043d\u043e\u0435 \u0438 \u043f\u0440\u043e\u043b\u0438\u0442\u044c \u0441\u0432\u0435\u0442 \u043d\u0430 \u044d\u0442\u043e\u0442 \u0442\u0451\u043c\u043d\u044b\u0439 \u0443\u0433\u043e\u043b\u043e\u043a \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 backend \u043d\u0430 Node.JS (\u043e \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043c\u043d\u043e\u0433\u0438\u0435 \u0437\u043d\u0430\u044e\u0442, \u0434\u0430, \u044f \u0432 \u043a\u0443\u0440\u0441\u0435). \u0412\u0441\u0435\u0445 \u0437\u0430\u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043e\u0432\u0430\u0432\u0448\u0438\u0445\u0441\u044f \u043f\u0440\u043e\u0448\u0443 \u043f\u043e\u0434 \u043a\u0430\u0442.<\/p>\n<p>  <a name=\"habracut\"><\/a><\/p>\n<h2>\u041f\u0430\u0440\u0443 \u0441\u043b\u043e\u0432 \u043e \u0441\u0430\u043c\u043e\u043c PM2<\/h2>\n<p>  PM2 \u2014 \u044d\u0442\u043e \u043c\u0435\u043d\u0435\u0434\u0436\u0435\u0440 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432 \u0441 \u043e\u0442\u043a\u0440\u044b\u0442\u044b\u043c \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u043c \u043a\u043e\u0434\u043e\u043c, \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u044f\u044e\u0449\u0438\u0439\u0441\u044f \u043f\u043e\u0434 \u043b\u0438\u0446\u0435\u043d\u0437\u0438\u0435\u0439 AGPL-3.0. \u0412 \u043c\u043e\u043c\u0435\u043d\u0442 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0441\u0442\u0430\u0442\u044c\u0438 \u0438\u043c\u0435\u0435\u0442 ~350k \u0437\u0430\u0433\u0440\u0443\u0437\u043e\u043a \u0432 \u043d\u0435\u0434\u0435\u043b\u044e, \u0441\u043e\u0433\u043b\u0430\u0441\u043d\u043e \u0434\u0430\u043d\u043d\u044b\u043c NPM. \u0412 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u0432 \u0441\u0440\u0435\u0434\u0430\u0445, \u0433\u0434\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043d\u0430 NodeJS \u0438 \u0437\u0430\u0431\u044b\u0442\u044c \u043e \u043d\u0451\u043c (\u0441 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u043c\u0438 \u044f\u0437\u044b\u043a\u0430\u043c\u0438 \u0442\u043e\u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c, \u043d\u043e \u043e\u0431 \u044d\u0442\u043e\u043c \u043f\u043e\u0437\u0434\u043d\u0435\u0435), \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0438\u0439 \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0438 \u0433\u0438\u0431\u043a\u043e \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0442\u044c \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0443 \u043c\u0435\u0436\u0434\u0443 \u044f\u0434\u0440\u0430\u043c\u0438 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430. \u041d\u0435\u0431\u043e\u043b\u044c\u0448\u0430\u044f \u0432\u044b\u0440\u0435\u0437\u043a\u0430 \u0438\u0437 <a href=\"https:\/\/github.com\/Unitech\/pm2\" rel=\"nofollow\">\u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u044f PM2 \u043d\u0430 GitHub<\/a>:<\/p>\n<blockquote><p>PM2 is a production process manager for Node.js applications with a built-in load balancer. It allows you to keep applications alive forever, to reload them without downtime and to facilitate common system admin tasks.<\/p><\/blockquote>\n<p>  \u041c\u043d\u043e\u0433\u0438\u0435 \u043d\u043e\u0432\u0438\u0447\u043a\u0438 \u043f\u0440\u0438 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u0441\u0442\u0430\u043b\u043a\u0438\u0432\u0430\u044e\u0442\u0441\u044f \u0441 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u043e\u0439, \u043a\u043e\u0433\u0434\u0430 \u043f\u043e\u0441\u043b\u0435 \u00ab\u0432\u044b\u043a\u0430\u0442\u043a\u0438\u00bb \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043d\u0430 production \u0441\u0435\u0440\u0432\u0435\u0440, \u043d\u0435 \u0437\u043d\u0430\u044e\u0442 \u043a\u0430\u043a \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0435\u0433\u043e \u00ab\u043d\u0430\u0432\u0435\u0447\u043d\u043e\u00bb. \u041f\u0438\u0448\u0443\u0442 \u0432 SSH-\u043a\u043e\u043d\u0441\u043e\u043b\u0438 <code>set NODE_ENV=production &amp;&amp; node app.js<\/code>, \u0432\u0441\u0451 \u043e\u0442\u043b\u0438\u0447\u043d\u043e, \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442. \u0417\u0430\u043a\u0440\u044b\u0432\u0430\u044e\u0442 \u043a\u043e\u043d\u0441\u043e\u043b\u044c \u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442. \u0412\u043e\u043f\u0440\u043e\u0441 \u043d\u0430 StackOverflow \u2014 <a href=\"https:\/\/stackoverflow.com\/questions\/12701259\/how-to-make-a-node-js-application-run-permanently\" rel=\"nofollow\">How to run node.js application permanently?<\/a> \u043d\u0430\u0431\u0440\u0430\u043b \u0431\u043e\u043b\u0435\u0435 237 \u0442\u044b\u0441. \u043f\u0440\u043e\u0441\u043c\u043e\u0442\u0440\u043e\u0432 \u0437\u0430 \u0432\u0441\u0451 \u0432\u0440\u0435\u043c\u044f.<\/p>\n<p>  PM2 \u0440\u0435\u0448\u0430\u0435\u0442 \u044d\u0442\u0443 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443 \u043e\u0434\u043d\u043e\u0439 \u043a\u043e\u043c\u0430\u043d\u0434\u043e\u0439:<\/p>\n<pre><code class=\"bash\">pm2 start app.js<\/code><\/pre>\n<p>  \u042d\u0442\u0430 \u043a\u043e\u043c\u0430\u043d\u0434\u0430 \u00ab\u0434\u0435\u043c\u043e\u043d\u0438\u0437\u0438\u0440\u0443\u0435\u0442\u00bb (\u043e\u0442 \u0430\u043d\u0433\u043b. \u00abdaemonize\u00bb) \u043f\u0440\u043e\u0446\u0435\u0441\u0441 NodeJS, \u0441\u043b\u0435\u0434\u0438\u0442 \u0437\u0430 \u043f\u043e\u0442\u0440\u0435\u0431\u043b\u0435\u043d\u0438\u0435\u043c \u0438\u043c \u043f\u0430\u043c\u044f\u0442\u0438 \u0438 \u0441\u0447\u0438\u0442\u0430\u0435\u0442 \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0443 \u043d\u0430 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440.<\/p>\n<h2>\u0412\u0435\u0440\u043d\u0451\u043c\u0441\u044f \u043a \u043d\u0430\u0448\u0438\u043c \u0431\u0430\u0440\u0430\u043d\u0430\u043c<\/h2>\n<p>  \u0421 \u0440\u043e\u0441\u0442\u043e\u043c \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u043d\u0430 backend \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c \u0435\u0433\u043e \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u2014 \u043a\u0430\u043a \u0432\u0435\u0440\u0442\u0438\u043a\u0430\u043b\u044c\u043d\u043e\u0433\u043e, \u0442\u0430\u043a \u0438 \u0433\u043e\u0440\u0438\u0437\u043e\u043d\u0442\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u2014 \u043a\u043e\u043c\u0443 \u0447\u0442\u043e \u0443\u0434\u043e\u0431\u043d\u0435\u0435 \u0432 \u0441\u043b\u043e\u0436\u0438\u0432\u0448\u0438\u0445\u0441\u044f \u043e\u0431\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u0441\u0442\u0432\u0430\u0445. \u041a\u0430\u043a \u043c\u044b \u0437\u043d\u0430\u0435\u043c, \u043e\u0434\u0438\u043d \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u043c\u043e\u0436\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u044f\u0434\u0435\u0440 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430, \u043d\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u0435\u0441\u043b\u0438 \u0432\u043d\u0443\u0442\u0440\u0438 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 \u0438\u043c\u0435\u0435\u0442\u0441\u044f \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0442\u043e\u043a\u043e\u0432. \u0412 NodeJS \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f\u0445 \u043f\u043e\u0442\u043e\u043a \u2014 \u043e\u0434\u0438\u043d. PM2 \u0441\u043f\u043e\u0441\u043e\u0431\u0435\u043d \u0432\u044b\u0440\u0443\u0447\u0438\u0442\u044c \u0432 \u044d\u0442\u043e\u0439 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0438 \u0438 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0443 \u043c\u0435\u0436\u0434\u0443 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u043c\u0438 \u044f\u0434\u0440\u0430\u043c\u0438 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430. \u041f\u043e-\u043f\u0440\u0435\u0436\u043d\u0435\u043c\u0443 \u0432\u0441\u0435\u0433\u043e \u0441 \u043e\u0434\u043d\u043e\u0439 \u043a\u043e\u043c\u0430\u043d\u0434\u043e\u0439:<\/p>\n<pre><code class=\"plaintext\">pm2 start app.js -i max<\/code><\/pre>\n<p>  \u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 <i>max<\/i> \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0443 \u044f\u0434\u0435\u0440 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430. \u0422.\u0435. \u0434\u043b\u044f 8-\u044f\u0434\u0435\u0440\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430 \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u043d\u043e 8 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0445 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432. \u041c\u043e\u0436\u043d\u043e \u0442\u0430\u043a\u0436\u0435 \u0432\u043c\u0435\u0441\u0442\u043e <i>max<\/i> \u0437\u0430\u0434\u0430\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 <i>-1<\/i> \u0438 \u0442\u043e\u0433\u0434\u0430 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432 \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c <i>\u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e_\u044f\u0434\u0435\u0440 \u043c\u0438\u043d\u0443\u0441 1<\/i>. \u0412\u0441\u044f \u043f\u0440\u0435\u043b\u0435\u0441\u0442\u044c \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u0438 HTTP(S)\/Websocket\/TCP\/UDP \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f \u0431\u0443\u0434\u0443\u0442 \u0440\u0430\u0432\u043d\u043e\u043c\u0435\u0440\u043d\u043e \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u044b \u043c\u0435\u0436\u0434\u0443 \u044d\u0442\u0438\u043c\u0438 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430\u043c\u0438. \u041d\u0443 \u0447\u0435\u043c \u043d\u0435 \u0433\u043e\u0440\u0438\u0437\u043e\u043d\u0442\u0430\u043b\u044c\u043d\u043e\u0435 \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435? \u041f\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u043e \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0438\u0437\u0430\u0446\u0438\u0438 \u0432 PM2 \u043c\u043e\u0436\u043d\u043e \u043f\u043e \u0441\u0441\u044b\u043b\u043a\u0435 \u2014 <a href=\"https:\/\/pm2.keymetrics.io\/docs\/usage\/cluster-mode\/\" rel=\"nofollow\">PM2 Cluster Mode<\/a>.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/a46\/084\/b81\/a46084b8119afc457b9d0692678fe7f9.png\" alt=\"cluster_mode\"><\/p>\n<p>  \u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0443\u0433\u043e\u0434\u043d\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432, \u043d\u043e \u0432\u0441\u0451 \u0436\u0435 \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u0435\u0442\u0441\u044f \u043f\u0440\u0438\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0442\u044c\u0441\u044f \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0430\u0446\u0438\u0438 \u00ab\u043e\u0434\u0438\u043d \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u043d\u0430 \u043e\u0434\u043d\u043e \u044f\u0434\u0440\u043e\u00bb.<\/p>\n<h3>\u0411\u0435\u0440\u0435\u0436\u043d\u043e\u0435 \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u0435 \u043a \u043f\u0430\u043c\u044f\u0442\u0438<\/h3>\n<p>  \u041f\u0440\u0438 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u043d\u0430 PHP \u044f \u043e\u0434\u043d\u0430\u0436\u0434\u044b \u0441\u0442\u043e\u043b\u043a\u043d\u0443\u043b\u0441\u044f \u0441 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u043e\u0439. \u041f\u043e \u043d\u0435\u043e\u043f\u044b\u0442\u043d\u043e\u0441\u0442\u0438 \u043d\u0435\u043e\u0441\u043e\u0437\u043d\u0430\u043d\u043d\u043e \u0437\u0430\u043b\u043e\u0436\u0438\u043b \u0432 \u0434\u0432\u0438\u0436\u043e\u043a \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u0431\u0430\u0433, \u0438\u0437-\u0437\u0430 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043f\u0440\u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u044b\u0445 \u0443\u0441\u043b\u043e\u0432\u0438\u044f\u0445 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u044b \u043d\u0430\u0447\u0438\u043d\u0430\u043b\u0438 \u043f\u043e\u0435\u0434\u0430\u0442\u044c \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u043c\u043d\u043e\u0433\u043e \u043e\u043f\u0435\u0440\u0430\u0442\u0438\u0432\u043d\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438. \u0412\u0434\u043e\u0431\u0430\u0432\u043e\u043a \u043a \u044d\u0442\u043e\u043c\u0443 \u043d\u0430\u0433\u0440\u0443\u0436\u0430\u043b\u0441\u044f \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440, \u0438\u0437-\u0437\u0430 \u0447\u0435\u0433\u043e \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u0430\u044f \u043c\u0430\u0448\u0438\u043d\u0430 \u043f\u0440\u043e\u0441\u0442\u043e \u0437\u0430\u0432\u0438\u0441\u043b\u0430 \u0438 \u0443 \u043c\u0435\u043d\u044f \u043d\u0435 \u0431\u044b\u043b\u043e \u043a \u043d\u0435\u0439 \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u0441\u043e\u0432\u0441\u0435\u043c.<br \/>  \u041a\u0430\u043a \u0437\u043d\u0430\u044e\u0442 PHP-\u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438, \u0432 PHP-FPM \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u0434\u0430\u0442\u044c \u0442\u0438\u043f \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432 (\u0435\u0441\u043b\u0438 \u0432\u044b \u0432\u0434\u0440\u0443\u0433 \u043d\u0435 \u0437\u043d\u0430\u043b\u0438, \u0442\u043e \u0432 PHP-FPM \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043d\u043e\u0432\u043e\u0433\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0441\u043e\u0437\u0434\u0430\u0451\u0442\u0441\u044f \u043d\u043e\u0432\u044b\u0439 \u043f\u0440\u043e\u0446\u0435\u0441\u0441) \u2014 \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439, \u043a\u043e\u0433\u0434\u0430 \u0437\u0430\u0434\u0430\u0451\u0442\u0441\u044f \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0439 \u0438 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0439 \u043f\u043e\u0440\u043e\u0433, \u0438 \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u2014 \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0441\u043a\u043e\u043b\u044c \u0443\u0433\u043e\u0434\u043d\u043e \u0431\u043e\u043b\u044c\u0448\u043e\u0433\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432, \u043f\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438. \u0427\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0432 PM2, \u0435\u0441\u043b\u0438 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c 8 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432 \u0438 \u0432\u0441\u0435 \u043e\u043d\u0438 \u043d\u0430\u0447\u043d\u0443\u0442 \u043f\u043e\u0442\u0440\u0435\u0431\u043b\u044f\u0442\u044c \u043c\u043d\u043e\u0433\u043e \u043f\u0430\u043c\u044f\u0442\u0438? \u0418 \u044d\u0442\u0443 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443 PM2 \u0432 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0438 \u0440\u0435\u0448\u0438\u0442\u044c \u2014 \u043b\u0438\u0448\u044c \u043e\u0434\u043d\u0438\u043c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u043c \u0432 \u043a\u043e\u043c\u0430\u043d\u0434\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0435:<\/p>\n<pre><code class=\"plaintext\"># Set memory threshold for app reload pm2 start app.js -i max --max-memory-restart &lt;200MB&gt; <\/code><\/pre>\n<p>  \u041a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437 \u043f\u0440\u0438 \u0434\u043e\u0441\u0442\u0438\u0436\u0435\u043d\u0438\u0438 \u043b\u0438\u043c\u0438\u0442\u0430 \u043f\u043e \u043f\u0430\u043c\u044f\u0442\u0438 PM2 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442 \u043f\u0440\u043e\u0446\u0435\u0441\u0441. \u0420\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0442\u044c \u043f\u0430\u043c\u044f\u0442\u044c \u043f\u0440\u043e\u0449\u0435 \u0447\u0435\u043c \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u044b, \u043d\u0435 \u0442\u0430\u043a \u043b\u0438? 8 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432 * 200 \u043c\u0435\u0433\u0430\u0431\u0430\u0439\u0442 = 1,6 \u0433\u0438\u0433\u0430\u0431\u0430\u0439\u0442. \u041c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u043a\u0430 \u0443\u0440\u043e\u0432\u043d\u044f \u0432\u0442\u043e\u0440\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430.<\/p>\n<p>  \u041f\u043e\u043c\u0438\u043c\u043e \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 \u043c\u043e\u0436\u043d\u043e \u0442\u0430\u043a\u0436\u0435 \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0438 \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0443\u0441\u043a \u0447\u0435\u0440\u0435\u0437 N \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b \u0432\u0440\u0435\u043c\u0435\u043d\u0438. \u042f \u043f\u043e\u043a\u0430 \u043d\u0435 \u043f\u0440\u0438\u0434\u0443\u043c\u0430\u043b \u0432 \u043a\u0430\u043a\u0438\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 \u044d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u0438\u0433\u043e\u0434\u0438\u0442\u044c\u0441\u044f, \u043d\u043e \u043d\u0435 \u0441\u0442\u0435\u0441\u043d\u044f\u0439\u0442\u0435\u0441\u044c \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u043c\u043d\u0435 \u043d\u0430 \u043f\u0430\u0440\u0443 \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u0432 \u0432 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u0445 \ud83d\ude42<\/p>\n<h3>\u0410 \u0435\u0441\u043b\u0438 \u044f \u043f\u0435\u0440\u0435\u0437\u0430\u0433\u0440\u0443\u0436\u0443 \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u0443\u044e \u043c\u0430\u0448\u0438\u043d\u0443?<\/h3>\n<p>  \u0421\u044e\u0440\u043f\u0440\u0438\u0437-\u0441\u044e\u0440\u043f\u0440\u0438\u0437! \u042d\u0442\u0443 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443 PM2 \u0442\u043e\u0436\u0435 \u0440\u0435\u0448\u0430\u0435\u0442 \u0437\u0430 \u0432\u0430\u0441. \u0412\u0441\u0451 \u0435\u0449\u0451 \u043d\u0435 \u0431\u043e\u043b\u0435\u0435 \u0447\u0435\u043c \u043e\u0434\u043d\u043e\u0439 \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0439 \u043a\u043e\u043c\u0430\u043d\u0434\u043e\u0439 \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u0438:<\/p>\n<pre><code class=\"plaintext\">pm2 startup<\/code><\/pre>\n<p>  PM2 \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442 \u0441\u043a\u0440\u0438\u043f\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u0434\u043d\u0438\u043c\u0430\u0442\u044c \u0432\u0441\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u044b \u043f\u0440\u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u044b. \u041e\u0434\u043d\u0430\u043a\u043e \u0437\u0434\u0435\u0441\u044c \u0441\u0442\u043e\u0438\u0442 \u0431\u044b\u0442\u044c \u0431\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u043c \u2014 \u043f\u0440\u0438 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0438 \u0432\u0435\u0440\u0441\u0438\u0438 Node.JS \u0432\u0441\u0451 \u043c\u043e\u0436\u0435\u0442 \u0441\u043b\u043e\u043c\u0430\u0442\u044c\u0441\u044f. \u0412\u043e \u0438\u0437\u0431\u0435\u0436\u0430\u043d\u0438\u0435 \u044d\u0442\u043e\u0433\u043e, \u043f\u043e\u0441\u043b\u0435 \u0443\u0441\u043f\u0435\u0448\u043d\u043e\u0433\u043e \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u0434\u043e \u043d\u043e\u0432\u043e\u0439 \u0432\u0435\u0440\u0441\u0438\u0438 Node.JS \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u0435 <code>pm2 unstartup<\/code> \u0438 <code>pm2 startup<\/code>. \u041f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u043e\u0431 \u044d\u0442\u043e\u043c \u043c\u043e\u0436\u043d\u043e \u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0442\u044c\u0441\u044f \u043f\u043e \u0441\u0441\u044b\u043b\u043a\u0435 \u2014 <a href=\"https:\/\/pm2.keymetrics.io\/docs\/usage\/startup\/\" rel=\"nofollow\">PM2 Startup Script Generator<\/a>.<\/p>\n<h3>\u0410 \u043d\u0430\u0434\u043e \u043b\u0438 \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u044b \u0432\u0440\u0443\u0447\u043d\u0443\u044e \u043f\u0440\u0438 \u0432\u043d\u0435\u0441\u0435\u043d\u0438\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439?<\/h3>\n<p>  \u041a\u043e\u043d\u0435\u0447\u043d\u043e \u0436\u0435 \u043d\u0435\u0442! \u041d\u0443, \u0442\u043e\u0447\u043d\u0435\u0435, \u0432\u044b, \u043a\u043e\u043d\u0435\u0447\u043d\u043e, \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0432\u0440\u0443\u0447\u043d\u0443\u044e, \u043d\u043e \u0437\u0430\u0447\u0435\u043c? \u0410\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0438\u0440\u0443\u0439\u0442\u0435 \u0432\u0441\u0451 \u0447\u0442\u043e \u043c\u043e\u0436\u0435\u0442\u0435 \u0438 \u0434\u0430 \u043f\u0440\u0438\u0431\u0443\u0434\u0435\u0442 \u0441 \u0432\u0430\u043c\u0438 \u0441\u0438\u043b\u0430!<\/p>\n<pre><code class=\"plaintext\">pm2 start env.js --watch --ignore-watch=\"node_modules\"<\/code><\/pre>\n<p>  \u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u044d\u0442\u0438\u043c \u043f\u0440\u0438 \u0441\u043b\u0438\u044f\u043d\u0438\u0438 master-\u0432\u0435\u0442\u043a\u0438 \u0432 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u043c \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438 \u0441 master-\u0432\u0435\u0442\u043a\u043e\u0439 \u0438\u0437 \u0443\u0434\u0430\u043b\u0451\u043d\u043d\u043e\u0433\u043e \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u044f. \u0412 \u043c\u043e\u0451\u043c \u0441\u0430\u0439\u0434-\u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u044d\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0441\u0442\u043e \u2014 <code>git pull origin master &amp;&amp; npm run build<\/code>. \u041f\u0440\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0438 \u0444\u0430\u0439\u043b\u043e\u0432 \u0432 \u043f\u0430\u043f\u043a\u0430\u0445 <i>server\/build<\/i> \u0438 <i>client\/build<\/i> \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u044b \u0431\u0443\u0434\u0443\u0442 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0443\u0449\u0435\u043d\u044b. \u042f \u043f\u043e\u043d\u0438\u043c\u0430\u044e, \u044d\u0442\u043e \u043e\u0447\u0435\u043d\u044c \u043f\u0440\u043e\u0441\u0442\u0435\u043d\u044c\u043a\u0430\u044f \u0444\u0438\u0447\u0430 \u0438 \u043e\u043d\u0430 \u043d\u0435 \u0437\u0430\u0441\u043b\u0443\u0436\u0438\u0432\u0430\u0435\u0442 \u0434\u0430\u0436\u0435 \u0431\u044b\u0442\u044c \u0443\u043f\u043e\u043c\u044f\u043d\u0443\u0442\u043e\u0439 \u0432 \u044d\u0442\u043e\u043c \u0442\u0435\u043a\u0441\u0442\u0435. \u0420\u0430\u0437\u0431\u0430\u0432\u043b\u044e \u0435\u0433\u043e \u043a\u043e\u0435-\u0447\u0435\u043c \u0441\u0435\u0440\u044c\u0451\u0437\u043d\u044b\u043c \u0438 \u043d\u0430\u043f\u0438\u0448\u0443 \u043e \u0442\u043e\u043c, \u0447\u0442\u043e \u0435\u0441\u043b\u0438 \u0432\u044b \u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0435\u0441\u044c \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0438\u0437\u0430\u0446\u0438\u0435\u0439, \u0442\u043e \u0432\u0441\u0435 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u044b \u0431\u0443\u0434\u0443\u0442 \u043f\u0435\u0440\u0435\u0437\u0430\u0433\u0440\u0443\u0436\u0435\u043d\u044b \u043f\u043e\u043e\u0447\u0435\u0440\u0451\u0434\u043d\u043e. \u0414\u0430 \u0442\u0430\u043a, \u0447\u0442\u043e \u043a\u0430\u043a \u043c\u0438\u043d\u0438\u043c\u0443\u043c \u043e\u0434\u0438\u043d \u0438\u0437 \u043d\u0438\u0445 \u0431\u0443\u0434\u0435\u0442 \u0432\u0441\u0435\u0433\u0434\u0430 \u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d. \u042d\u0442\u043e \u0436\u0435 zero-downtime deployment!<\/p>\n<p>  \u0410 \u043c\u043e\u0436\u043d\u043e \u0438 \u043d\u0435 \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u044b. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0435\u0441\u0442\u044c reload (\u043d\u0435\u0447\u0442\u043e \u043f\u043e\u0445\u043e\u0436\u0435\u0435 \u043d\u0430 nginx reload):<\/p>\n<pre><code class=\"plaintext\">pm2 reload all<\/code><\/pre>\n<h3>\u0421\u043b\u0438\u0448\u043a\u043e\u043c \u043c\u043d\u043e\u0433\u043e \u043a\u043e\u043c\u0430\u043d\u0434! \u0418 \u0432\u043e\u043e\u0431\u0449\u0435 \u044f \u043f\u0440\u0435\u0434\u043f\u043e\u0447\u0438\u0442\u0430\u044e \u043a\u043e\u043d\u0444\u0438\u0433\u0438 <\/h3>\n<p>  \u041c\u043d\u0435 \u0443\u0436\u0435 \u043d\u0430\u0441\u043a\u0443\u0447\u0438\u043b\u043e \u043f\u0440\u0438\u0434\u0443\u043c\u044b\u0432\u0430\u0442\u044c \u0432\u0435\u0441\u0451\u043b\u044b\u0435 \u0444\u0440\u0430\u0437\u044b, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0440\u043e\u0441\u0442\u043e \u0438 \u0431\u0430\u043d\u0430\u043b\u044c\u043d\u043e: \u0444\u0430\u0439\u043b \u044d\u043a\u043e\u0441\u0438\u0441\u0442\u0435\u043c\u044b \u2014 \u0435\u0441\u0442\u044c. \u041f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u044e\u0442\u0441\u044f \u0444\u043e\u0440\u043c\u0430\u0442\u044b JSON, YAML \u0438 JS. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043a\u043e\u0433\u0434\u0430 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0441\u043b\u0435\u0434\u0438\u0442\u044c \u0437\u0430 \u0444\u0430\u0439\u043b\u0430\u043c\u0438 \u0432 \u043f\u0430\u043f\u043a\u0430\u0445 <i>server<\/i> \u0438 <i>client<\/i>:<\/p>\n<pre><code class=\"javascript\">module.exports = {   apps: [{     script: \"app.js\",     watch: [\"server\", \"client\"],     env_production : {       \"NODE_ENV\": \"production\"     }   }] } <\/code><\/pre>\n<p>  \u041f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0442\u044c\u0441\u044f \u043c\u043e\u0436\u043d\u043e \u043f\u043e \u0441\u0441\u044b\u043b\u043a\u0435 \u2014 <a href=\"https:\/\/pm2.keymetrics.io\/docs\/usage\/application-declaration\/\" rel=\"nofollow\">PM2 Application Declaration<\/a>.<\/p>\n<h3>\u0418 \u0434\u0430\u0436\u0435 \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433 \u0435\u0441\u0442\u044c!<\/h3>\n<p>  \u0418 \u043d\u0435 \u043e\u0434\u0438\u043d. \u0412\u044b\u0431\u0438\u0440\u0430\u0439\u0442\u0435 \u0442\u043e\u0442 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0440\u0430\u0432\u0438\u0442\u0441\u044f \u0431\u043e\u043b\u044c\u0448\u0435. \u041c\u043e\u0436\u043d\u043e \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u0442\u044c \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u0438 \u043a\u043e\u043c\u0430\u043d\u0434\u043e\u0439:<\/p>\n<pre><code class=\"plaintext\">pm2 monit<\/code><\/pre>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/8l\/y-\/c9\/8ly-c9ljx5qjvxscgu1nagmycrg.png\"><\/p>\n<p>  \u0418\u043b\u0438 \u0436\u0435 \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043f\u043e\u043b\u043d\u043e\u0446\u0435\u043d\u043d\u043e\u0439 \u0432\u0435\u0431-\u0432\u0435\u0440\u0441\u0438\u0435\u0439 \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433\u0430:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/0q\/u4\/mt\/0qu4mtcxqhdqd9ysabk5xelvzns.png\"><\/p>\n<p>  \u0412\u044b \u043c\u043d\u0435, \u043a\u043e\u043d\u0435\u0447\u043d\u043e \u0436\u0435, \u043d\u0435 \u043f\u043e\u0432\u0435\u0440\u0438\u0442\u0435, \u043d\u043e \u043e\u043d\u0430 \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442\u0441\u044f <b>\u043e\u0434\u043d\u043e\u0439<\/b> \u043a\u043e\u043c\u0430\u043d\u0434\u043e\u0439:<\/p>\n<pre><code class=\"plaintext\">pm2 plus<\/code><\/pre>\n<h3>\u0418 \u043c\u043d\u043e\u0433\u043e\u0435-\u043c\u043d\u043e\u0433\u043e\u0435 \u0434\u0440\u0443\u0433\u043e\u0435&#8230;<\/h3>\n<p>  \u0417\u0430\u044f\u0432\u043b\u0435\u043d\u0430 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430 Heroku \u0438 Docker, \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u0438\u043d\u043a\u0440\u0435\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043f\u043e\u0440\u0442\u043e\u0432 \u0441 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c\u044e \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438 \u0432 <code>process.env<\/code> (\u043a\u043e\u0433\u0434\u0430 \u043d\u0443\u0436\u043d\u043e \u043a\u0430\u0436\u0434\u044b\u0439 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u043d\u0430 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u043c \u043f\u043e\u0440\u0442\u0443), \u0437\u0430\u043f\u0443\u0441\u043a \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0438\u043d\u0441\u0442\u0430\u043d\u0441\u043e\u0432 PM2 \u0432 \u043f\u0440\u0435\u0434\u0435\u043b\u0430\u0445 \u043e\u0434\u043d\u043e\u0439 \u041e\u0421, \u043d\u0430\u043b\u0438\u0447\u0438\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u043d\u043e\u0433\u043e API \u0438 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u0434\u0435\u043c\u043e\u043d\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 Bash \u0438 Python \u0441\u043a\u0440\u0438\u043f\u0442\u044b!<\/p>\n<p>  \u0412\u0435\u0440\u043e\u044f\u0442\u043d\u043e, \u044f \u0443\u043f\u0443\u0441\u0442\u0438\u043b \u0435\u0449\u0451 \u0447\u0442\u043e-\u0442\u043e \u0432\u0430\u0436\u043d\u043e\u0435 \u0438\u043b\u0438 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e\u0435, \u043e \u0447\u0451\u043c \u0432\u0441\u0435\u0433\u0434\u0430 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u043f\u043e\u043c\u043d\u0438\u0442\u044c \u043c\u043d\u0435 \u0432 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u0445. \u041d\u0430\u0434\u0435\u044e\u0441\u044c, \u0447\u0442\u043e \u0432\u044b \u0441\u043c\u043e\u0433\u043b\u0438 \u043f\u043e\u0447\u0435\u0440\u043f\u043d\u0443\u0442\u044c \u0434\u043b\u044f \u0441\u0435\u0431\u044f \u0447\u0442\u043e-\u0442\u043e \u043d\u043e\u0432\u043e\u0435 \u0438\u0437 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438.<\/p><\/div>\n<p>               <script class=\"js-mediator-script\">!function(e){function t(t,n){if(!(n in e)){for(var r,a=e.document,i=a.scripts,o=i.length;o--;)if(-1!==i[o].src.indexOf(t)){r=i[o];break}if(!r){r=a.createElement(\"script\"),r.type=\"text\/javascript\",r.async=!0,r.defer=!0,r.src=t,r.charset=\"UTF-8\";var d=function(){var e=a.getElementsByTagName(\"script\")[0];e.parentNode.insertBefore(r,e)};\"[object Opera]\"==e.opera?a.addEventListener?a.addEventListener(\"DOMContentLoaded\",d,!1):e.attachEvent(\"onload\",d):d() } } }t(\"\/\/mediator.mail.ru\/script\/2820404\/\",\"_mediator\")}(window);<\/script>      <br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/480670\/\"> https:\/\/habr.com\/ru\/post\/480670\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html js-mediator-article\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/480670\/\">\u0411\u0443\u043a\u0432\u0430\u043b\u044c\u043d\u043e \u043f\u0430\u0440\u0443 \u0447\u0430\u0441\u043e\u0432 \u043d\u0430\u0437\u0430\u0434 \u0443 \u043c\u0435\u043d\u044f \u0437\u0430\u0432\u044f\u0437\u0430\u043b\u0441\u044f \u0441\u043f\u043e\u0440 \u043d\u0430 \u0442\u0435\u043c\u0443 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e Node.JS \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u0430\u044f \u0434\u043b\u044f \u043a\u0440\u0443\u043f\u043d\u044b\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u0432 \u0438 \u0435\u0439 \u0441\u0442\u043e\u0438\u0442 \u043f\u0440\u0435\u0434\u043f\u043e\u0447\u0435\u0441\u0442\u044c Golang, Rust, PHP, etc. \u041e\u0441\u043d\u043e\u0432\u043d\u044b\u043c \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u043c \u043f\u0440\u043e\u0442\u0438\u0432\u043e\u043f\u043e\u043b\u043e\u0436\u043d\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u044b \u0432 \u044d\u0442\u043e\u043c \u0441\u043f\u043e\u0440\u0435 \u0431\u044b\u043b \u0444\u0430\u043a\u0442 \u043e\u0434\u043d\u043e\u043f\u043e\u0442\u043e\u0447\u043d\u043e\u0441\u0442\u0438 JavaScript. \u042f\u043a\u043e\u0431\u044b \u043f\u0440\u0438 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u043e \u0443\u043f\u0440\u0451\u0442\u0441\u044f \u0432 \u044d\u0442\u0443 \u043e\u0434\u043d\u043e\u043f\u043e\u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c \u0438 \u043d\u0438\u0447\u0435\u0433\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0443\u0436\u0435 \u043d\u0435\u043b\u044c\u0437\u044f \u2014 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0435\u0440\u0435\u043f\u0438\u0441\u0430\u0442\u044c \u043d\u0430 \u043a\u0430\u043a\u043e\u043c-\u0442\u043e \u0434\u0440\u0443\u0433\u043e\u043c \u044f\u0437\u044b\u043a\u0435. \u041e\u0434\u043d\u0430\u043a\u043e \u0434\u0435\u043b\u0430 \u0441 \u044d\u0442\u0438\u043c \u0432 NodeJS \u043e\u0431\u0441\u0442\u043e\u044f\u0442 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043b\u0443\u0447\u0448\u0435, \u0447\u0435\u043c \u043a\u0430\u0436\u0435\u0442\u0441\u044f \u043d\u0430 \u043f\u0435\u0440\u0432\u044b\u0439 \u0432\u0437\u0433\u043b\u044f\u0434. \u041f\u0435\u0440\u0435\u0434 \u0442\u0435\u043c, \u043a\u0430\u043a \u043c\u044b \u0443\u0433\u043b\u0443\u0431\u0438\u043c\u0441\u044f \u0432 \u044d\u0442\u0443 \u0442\u0435\u043c\u0443 \u0445\u043e\u0447\u0443 \u0437\u0430\u044f\u0432\u0438\u0442\u044c, \u0447\u0442\u043e \u0443\u0432\u0430\u0436\u0430\u044e \u043f\u0440\u0430\u0432\u043e \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0442\u043e\u0442 \u044f\u0437\u044b\u043a \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u0438\u0448\u0451\u043b\u0441\u044f \u0435\u043c\u0443 \u043f\u043e \u0434\u0443\u0448\u0435 \u0438 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u043d \u0441\u0447\u0438\u0442\u0430\u0435\u0442 \u043f\u0440\u0435\u0434\u043f\u043e\u0447\u0442\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u043c \u0432 \u0442\u043e\u0439 \u0438\u043b\u0438 \u0438\u043d\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0435.<\/p>\n<p>  \u0421\u0434\u0435\u043b\u0430\u0432 \u043f\u043e\u0438\u0441\u043a \u043f\u043e \u043a\u043b\u044e\u0447\u0435\u0432\u043e\u043c\u0443 \u0441\u043b\u043e\u0432\u0443 \u00abPM2\u00bb \u043d\u0430 \u0425\u0430\u0431\u0440\u0435 \u044f \u043d\u0435 \u043d\u0430\u0448\u0451\u043b \u043d\u0438 \u043e\u0434\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438, \u043f\u043e\u0441\u0432\u044f\u0449\u0451\u043d\u043d\u043e\u0439 \u044d\u0442\u043e\u043c\u0443 process-\u043c\u0435\u043d\u0435\u0434\u0436\u0435\u0440\u0443. \u041b\u0438\u0448\u044c \u043e\u0434\u0438\u043d\u043e\u0447\u043d\u044b\u0435 \u0443\u043f\u043e\u043c\u0438\u043d\u0430\u043d\u0438\u044f \u0432 \u0441\u0442\u0430\u0442\u044c\u044f\u0445 \u0434\u0440\u0443\u0433\u0438\u0445 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439. \u042f \u0437\u0430\u0433\u043e\u0440\u0435\u043b\u0441\u044f (\u0441\u0438\u043b\u044c\u043d\u043e \u0441\u043a\u0430\u0437\u0430\u043d\u043e) \u0438\u0434\u0435\u0435\u0439 \u043d\u0430\u0432\u0435\u0440\u0441\u0442\u0430\u0442\u044c \u0443\u043f\u0443\u0449\u0435\u043d\u043d\u043e\u0435 \u0438 \u043f\u0440\u043e\u043b\u0438\u0442\u044c \u0441\u0432\u0435\u0442 \u043d\u0430 \u044d\u0442\u043e\u0442 \u0442\u0451\u043c\u043d\u044b\u0439 \u0443\u0433\u043e\u043b\u043e\u043a \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 backend \u043d\u0430 Node.JS (\u043e \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043c\u043d\u043e\u0433\u0438\u0435 \u0437\u043d\u0430\u044e\u0442, \u0434\u0430, \u044f \u0432 \u043a\u0443\u0440\u0441\u0435). \u0412\u0441\u0435\u0445 \u0437\u0430\u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043e\u0432\u0430\u0432\u0448\u0438\u0445\u0441\u044f \u043f\u0440\u043e\u0448\u0443 \u043f\u043e\u0434 \u043a\u0430\u0442.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-295482","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/295482","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=295482"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/295482\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=295482"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=295482"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=295482"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}