{"id":296684,"date":"2020-01-02T21:00:15","date_gmt":"2020-01-02T21:00:15","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=296684"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=296684","title":{"rendered":"nodejs: \u043c\u0435\u043d\u0435\u0434\u0436\u0435\u0440\u044b \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432 \u0438 ES6-\u043c\u043e\u0434\u0443\u043b\u0438"},"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\/482370\/\">\n<p>\u0412 \u043c\u0438\u0440\u0435 \u0441\u0435\u0440\u0432\u0435\u0440\u043d\u043e\u0433\u043e JavaScript&#8217;\u0430 \u044f \u2014 \u043d\u043e\u0432\u0438\u0447\u043e\u043a \u0441 \u0447\u0438\u0441\u0442\u044b\u043c, \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043d\u0435\u0437\u0430\u043c\u0443\u0442\u043d\u0451\u043d\u043d\u044b\u043c \u0440\u0430\u0437\u0443\u043c\u043e\u043c. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043a\u043e\u0433\u0434\u0430 \u044f \u0443\u0437\u043d\u0430\u043b \u043e \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043e\u0432\u0430\u043d\u0438\u0438 \u043c\u0435\u043d\u0435\u0434\u0436\u0435\u0440\u043e\u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432, \u0430 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e \u2014 \u043e <a href=\"https:\/\/habr.com\/ru\/post\/480670\/\">pm2<\/a>, \u0442\u043e \u0441\u0440\u0430\u0437\u0443 \u0436\u0435 \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u043b \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u044c \u0435\u0433\u043e \u0434\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u043a\u0430\u043a\u043e\u0433\u043e-\u043d\u0438\u0431\u0443\u0434\u044c \u043f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0435\u0433\u043e backend-\u0441\u0435\u0440\u0432\u0438\u0441\u0430 \u043d\u0430 <code>nodejs<\/code> \u0432 \u0446\u0435\u043b\u044f\u0445 \u0441\u0430\u043c\u043e\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044f. \u041c\u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u0438\u043c\u043f\u043e\u043d\u0438\u0440\u0443\u0435\u0442 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u043c\u043e\u0434\u0443\u043b\u0435\u0439 \u0432 JS-\u043a\u043e\u0434\u0435 \u0447\u0435\u0440\u0435\u0437 <code>import<\/code> (<a href=\"https:\/\/nodejs.org\/docs\/latest-v12.x\/api\/esm.html\">ES6 modules<\/a>), \u0442.\u043a. \u043e\u043d \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043e\u0434\u0438\u043d \u0438 \u0442\u043e\u0442 \u0436\u0435 \u043a\u043e\u0434 \u043a\u0430\u043a \u0432 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0435, \u0442\u0430\u043a \u0438 \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u043d\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u0435, \u0438 \u044f \u0437\u0430\u043f\u0438\u043b\u0438\u043b \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0441\u0435\u0440\u0432\u0438\u0441 \u0441 ES6-\u043c\u043e\u0434\u0443\u043b\u044f\u043c\u0438.<\/p>\n<p>  <\/p>\n<p>\u0415\u0441\u043b\u0438 \u0432\u043a\u0440\u0430\u0442\u0446\u0435, \u0442\u043e \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c ES6-\u0432\u0435\u0440\u0441\u0438\u044e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043f\u043e\u0434 <code>pm2<\/code> \u0443 \u043c\u0435\u043d\u044f \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c, \u0434\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0442\u0430\u043a\u0438\u0445 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439 \u043b\u0443\u0447\u0448\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043b\u0438\u0431\u043e <code>forever<\/code>, \u043b\u0438\u0431\u043e <code>systemd<\/code>. \u041f\u043e\u0434 \u043a\u0430\u0442\u043e\u043c \u2014 \u043e\u0442\u0447\u0451\u0442 \u043e \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430\u0445 \u0434\u043b\u044f \u0442\u0435\u0445, \u043a\u0442\u043e \u043b\u044e\u0431\u0438\u0442 \u0442\u0435\u043a\u0441\u0442\u044b \u043f\u043e\u0434\u043b\u0438\u043d\u0435\u0435.<\/p>\n<p><a name=\"habracut\"><\/a>  <\/p>\n<h1 id=\"vvedenie\">\u0412\u0432\u0435\u0434\u0435\u043d\u0438\u0435<\/h1>\n<p>  <\/p>\n<p>\u0412 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435 \u0434\u0430\u043d\u043d\u043e\u0439 \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u0438 \u043f\u043e\u0434 \u043c\u0435\u043d\u0435\u0434\u0436\u0435\u0440\u043e\u043c \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432 \u043f\u043e\u0434\u0440\u0430\u0437\u0443\u043c\u0435\u0432\u0430\u0435\u0442\u0441\u044f \u0441\u0435\u0440\u0432\u0438\u0441, \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0435\u0439 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433 \u0437\u0430\u043f\u0443\u0449\u0435\u043d\u043d\u043e\u0433\u043e <code>nodejs<\/code>-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0438 \u0435\u0433\u043e \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0443\u0441\u043a \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u043f\u0430\u0434\u0435\u043d\u0438\u044f. \u0422\u0430\u043a\u0436\u0435 \u043c\u0435\u043d\u0435\u0434\u0436\u0435\u0440 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432 \u043c\u043e\u0436\u0435\u0442 (\u043d\u043e \u043d\u0435 \u043e\u0431\u044f\u0437\u0430\u043d) \u0441\u043e\u0431\u0438\u0440\u0430\u0442\u044c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u043f\u043e\u0442\u0440\u0435\u0431\u043b\u044f\u0435\u043c\u044b\u0445 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435\u043c \u0440\u0435\u0441\u0443\u0440\u0441\u0430\u0445 (\u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440, \u043f\u0430\u043c\u044f\u0442\u044c).<\/p>\n<p>  <\/p>\n<h1 id=\"testovyy-servis\">\u0422\u0435\u0441\u0442\u043e\u0432\u044b\u0439 \u0441\u0435\u0440\u0432\u0438\u0441<\/h1>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043c\u0435\u043d\u0435\u0434\u0436\u0435\u0440\u043e\u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432 \u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b \u0432\u043e\u0442 \u0442\u0430\u043a\u043e\u0439 \u043a\u043e\u0434 \u0432 ES6-\u0441\u0435\u0440\u0432\u0438\u0441\u0435 (<a href=\"https:\/\/github.com\/flancer64\/sof_es6_pm\/tree\/habr_pm\">github repo<\/a>):<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\"># src\/app_es6.mjs import express from \"express\"; import mod from \".\/mod\/es6.mjs\";  const app = express(); const msg = \"Hello World! \" + mod.getName();  app.get(\"\/\", function (req, res) {     console.log(msg);     res.send(msg); });  app.listen(3000, function () {     console.log('ES6 app listening on port 3000!'); });<\/code><\/pre>\n<p>  <\/p>\n<p>\u0438 \u0432 ES6-\u043c\u043e\u0434\u0443\u043b\u0435:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\"># src\/mod\/es6.mjs export default {     getName: function () {         return \"ES6 module is here.\";     } }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0410\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u044b\u0439 \u0441\u0435\u0440\u0432\u0438\u0441, \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u043d\u044b\u0439 c CommonJS-\u043c\u043e\u0434\u0443\u043b\u044f\u043c\u0438 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\"># src\/app_cjs.js const express = require(\"express\"); const mod = require(\".\/mod\/cjs.js\"); const app = express();  const msg = \"Hello World! \" + mod.getName();  app.get(\"\/\", function (req, res) {     console.log(msg);     res.send(msg); });  app.listen(3000, function () {     console.log(\"CommonJS app listening on port 3000!\"); });<\/code><\/pre>\n<p>  <\/p>\n<p>CJS-\u043c\u043e\u0434\u0443\u043b\u044c:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\"># src\/mod\/cjs.js module.exports = {     getName: function () {         return \"CommonJS module is here.\";     } };<\/code><\/pre>\n<p>  <\/p>\n<p>\u0417\u0430\u043f\u0443\u0441\u043a \u0441\u0435\u0440\u0432\u0438\u0441\u0430 \u0431\u0435\u0437 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043c\u0435\u043d\u0435\u0434\u0436\u0435\u0440\u0430 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432 \u043d\u0430 <code>nodejs<\/code> v12.14.0:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">$  node --experimental-modules .\/src\/app_es6.mjs    # ES6-service $  node .\/src\/app_cjs.js    # CJS-service<\/code><\/pre>\n<p>  <\/p>\n<h1 id=\"pm2\">pm2<\/h1>\n<p>  <\/p>\n<p><code>pm2<\/code> \u043d\u0430 \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043b\u0438\u0434\u0435\u0440\u043e\u043c \u0441\u0440\u0435\u0434\u0438 \u043c\u0435\u043d\u0435\u0434\u0436\u0435\u0440\u043e\u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432 \u043f\u043e \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u0435\u043c\u043e\u043c\u0443 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u0443 (\u043f\u043e\u043c\u0438\u043c\u043e \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0430\u043d\u0438\u044f \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 \u0432 \u0440\u0430\u0431\u043e\u0447\u0435\u043c \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0438 \u0442\u0430\u043a\u0436\u0435 \u0435\u0441\u0442\u044c <a href=\"https:\/\/pm2.keymetrics.io\/docs\/usage\/cluster-mode\/\">\u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0438\u0437\u0430\u0446\u0438\u044f<\/a>, <a href=\"https:\/\/pm2.keymetrics.io\/docs\/usage\/monitoring\/\">\u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433<\/a> \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432, \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 <a href=\"https:\/\/pm2.keymetrics.io\/docs\/usage\/restart-strategies\/\">\u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u0438 \u0440\u0435\u0441\u0442\u0430\u0440\u0442\u0430<\/a> \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432).<\/p>\n<p>  <\/p>\n<p>CJS-\u0441\u0435\u0440\u0432\u0438\u0441 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442\u0441\u044f \u0431\u0435\u0437 \u043f\u0440\u043e\u0431\u043b\u0435\u043c (<code>pm2<\/code> v4.2.1):<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">$ pm2 start .\/src\/app_cjs.js -i 4<\/code><\/pre>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/cx\/tu\/9m\/cxtu9mfzw3hkqq-si7h_brbfejy.png\"><\/p>\n<p>  <\/p>\n<p>\u0442\u0430\u043a\u0436\u0435 \u0431\u0435\u0437 \u043f\u0440\u043e\u0431\u043b\u0435\u043c \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u043e\u0432 \u0441\u0435\u0440\u0432\u0438\u0441\u0430 \u0432 \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0435:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">root@omen17:~# ps -Af | grep app_cjs alex     29848 29828  0 15:31 ?        00:00:00 node \/...\/src\/app_cjs.js alex     29855 29828  0 15:31 ?        00:00:00 node \/...\/src\/app_cjs.js alex     29864 29828  0 15:31 ?        00:00:00 node \/...\/src\/app_cjs.js alex     29875 29828  0 15:31 ?        00:00:00 node \/...\/src\/app_cjs.js<\/code><\/pre>\n<p>  <\/p>\n<p>\u041f\u043e\u0441\u043b\u0435 &#171;\u0443\u0431\u0438\u0439\u0441\u0442\u0432\u0430&#187; \u043e\u0434\u043d\u043e\u0433\u043e \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0430 (<code>PID 29864<\/code>) \u043c\u0435\u043d\u0435\u0434\u0436\u0435\u0440 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432 \u0441\u0440\u0430\u0437\u0443 \u0436\u0435 \u043f\u043e\u0434\u043d\u044f\u043b \u043d\u043e\u0432\u044b\u0439 (<code>PID 30703<\/code>):<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">root@omen17:~# kill -s SIGKILL 29864 root@omen17:~# ps -Af | grep app_cjs alex     29848 29828  0 15:31 ?        00:00:00 node \/...\/src\/app_cjs.js alex     29855 29828  0 15:31 ?        00:00:00 node \/...\/src\/app_cjs.js alex     29875 29828  0 15:31 ?        00:00:00 node \/...\/src\/app_cjs.js alex     30703 29828  7 15:35 ?        00:00:00 node \/...\/src\/app_cjs.js<\/code><\/pre>\n<p>  <\/p>\n<p>\u041d\u043e ES6-\u0432\u0435\u0440\u0441\u0438\u044f \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043d\u0435 \u043e\u0442\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442 \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e \u0432 <code>pm2<\/code>. \u041f\u0440\u0438 <a href=\"https:\/\/futurestud.io\/tutorials\/pm2-how-to-start-your-app-with-node-js-v8-arguments\">\u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0435<\/a> \u0432 nodejs \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430 &#171;&#8212;experimental-modules&#187;:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">$ pm2 start .\/src\/app_es6.mjs -i 4 --node-args=\"--experimental-modules\"<\/code><\/pre>\n<p>  <\/p>\n<p>\u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u0432\u043e\u0442 \u0442\u0430\u043a\u0430\u044f \u043a\u0430\u0440\u0442\u0438\u043d\u0430:<br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/ur\/y_\/a3\/ury_a3oh7cfqa-gj1-107tcxwx8.png\"><\/p>\n<p>  <\/p>\n<p>\u0412 \u043b\u043e\u0433\u0430\u0445 \u0432\u0438\u0434\u0438\u043c:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">$ pm2 log ... \/home\/alex\/.pm2\/logs\/app-es6-error-2.log last 15 lines: 2|app_es6  |     at \/usr\/lib\/node_modules\/pm2\/node_modules\/async\/internal\/onlyOnce.js:12:16 2|app_es6  |     at WriteStream.&lt;anonymous&gt; (\/usr\/lib\/node_modules\/pm2\/lib\/Utility.js:186:13) 2|app_es6  |     at WriteStream.emit (events.js:210:5) 2|app_es6  |     at internal\/fs\/streams.js:299:10 2|app_es6  | Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: \/home\/alex\/work\/sof_es6_pm\/src\/app_es6.mjs 2|app_es6  |     at Object.Module._extensions..mjs (internal\/modules\/cjs\/loader.js:1029:9) 2|app_es6  |     at Module.load (internal\/modules\/cjs\/loader.js:815:32) 2|app_es6  |     at Function.Module._load (internal\/modules\/cjs\/loader.js:727:14) 2|app_es6  |     at \/usr\/lib\/node_modules\/pm2\/lib\/ProcessContainer.js:297:23 2|app_es6  |     at wrapper (\/usr\/lib\/node_modules\/pm2\/node_modules\/async\/internal\/once.js:12:16) 2|app_es6  |     at next (\/usr\/lib\/node_modules\/pm2\/node_modules\/async\/waterfall.js:96:20) 2|app_es6  |     at \/usr\/lib\/node_modules\/pm2\/node_modules\/async\/internal\/onlyOnce.js:12:16 2|app_es6  |     at WriteStream.&lt;anonymous&gt; (\/usr\/lib\/node_modules\/pm2\/lib\/Utility.js:186:13) 2|app_es6  |     at WriteStream.emit (events.js:210:5) 2|app_es6  |     at internal\/fs\/streams.js:299:10<\/code><\/pre>\n<p>  <\/p>\n<p>\u0422\u043e \u0435\u0441\u0442\u044c, \u043f\u043e \u0444\u0430\u043a\u0442\u0443 <code>pm2<\/code> <a href=\"https:\/\/github.com\/Unitech\/pm2\/issues?utf8=%E2%9C%93&amp;q=is%3Aissue+is%3Aopen+experimental-modules\">\u043d\u0435 \u043c\u043e\u0436\u0435\u0442<\/a> \u0431\u0435\u0437 \u0442\u0440\u0430\u043d\u0441\u043f\u0438\u043b\u044f\u0446\u0438\u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u0441\u043a\u0440\u0438\u043f\u0442\u044b, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f ES6-\u043c\u043e\u0434\u0443\u043b\u0438. \u041f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 <a href=\"https:\/\/github.com\/Unitech\/pm2\/issues\/4540\">issue<\/a> \u043d\u0430 \u044d\u0442\u0443 \u0442\u0435\u043c\u0443 \u0441\u043e\u0437\u0434\u0430\u043d 5 \u0434\u0435\u043a\u0430\u0431\u0440\u044f 2019 (\u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u043c\u0435\u0441\u044f\u0446 \u043d\u0430\u0437\u0430\u0434).<\/p>\n<p>  <\/p>\n<h1 id=\"forever\">forever<\/h1>\n<p>  <\/p>\n<p><code>forever<\/code> \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043f\u043e \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u043e\u0441\u0442\u0438 \u043c\u0435\u043d\u0435\u0434\u0436\u0435\u0440\u043e\u043c \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432 \u043f\u043e\u0441\u043b\u0435 <code>pm2<\/code> (<a href=\"https:\/\/www.npmtrends.com\/forever-vs-pm2\">npmtrends<\/a>). \u042d\u0442\u043e \u0431\u043e\u043b\u0435\u0435 \u0441\u0442\u0430\u0440\u044b\u0439 \u043f\u0440\u043e\u0435\u043a\u0442 (\u043d\u0430\u0447\u0430\u0442 \u0432 2010 \u0433\u043e\u0434\u0443 \u043f\u0440\u043e\u0442\u0438\u0432 2013 \u0434\u043b\u044f <code>pm2<\/code>), \u043d\u043e \u0443 \u043d\u0435\u0433\u043e \u0431\u043e\u043b\u0435\u0435 \u0443\u0437\u043a\u0438\u0439 \u0444\u043e\u043a\u0443\u0441 \u043f\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u0438, \u0447\u0435\u043c \u0443 <code>pm2<\/code>. <code>forever<\/code> &#171;\u0437\u0430\u0442\u043e\u0447\u0435\u043d&#187; \u043d\u0430 \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u043e\u0435 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0430\u043d\u0438\u0435 \u0440\u0430\u0431\u043e\u0442\u043e\u0441\u043f\u043e\u0441\u043e\u0431\u043d\u043e\u0441\u0442\u0438 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 \u0431\u0435\u0437 \u0432\u0441\u044f\u043a\u0438\u0445 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 <code>pm2<\/code>-\u043f\u043b\u044e\u0448\u0435\u043a \u0432 \u0432\u0438\u0434\u0435 \u0431\u0430\u043b\u0430\u043d\u0441\u0438\u0440\u043e\u0432\u043a\u0438 \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u0438 \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0445 \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432. \u0421\u0443\u0434\u044f <a href=\"https:\/\/github.com\/foreversd\/forever\/commits\/master\">\u043f\u043e \u0447\u0430\u0441\u0442\u043e\u0442\u0435 \u043a\u043e\u043c\u043c\u0438\u0442\u043e\u0432<\/a> \u043f\u0440\u043e\u0435\u043a\u0442 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0432 \u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u043e\u043c \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0438 (\u0444\u0430\u0437\u0443 \u0430\u043a\u0442\u0438\u0432\u043d\u043e\u0433\u043e \u0440\u0430\u0437\u0432\u0438\u0442\u0438\u044f \u0443\u0436\u0435 \u043f\u0440\u043e\u0448\u0451\u043b) \u0438 \u043a\u0430\u043a\u0438\u0445-\u0442\u043e \u043d\u043e\u0432\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u043e\u0442 \u043d\u0435\u0433\u043e \u0436\u0434\u0430\u0442\u044c \u043d\u0435 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f. \u042f \u043d\u0435 \u043d\u0430\u0448\u0451\u043b \u0441\u043f\u043e\u0441\u043e\u0431\u0430 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u0432 <code>nodejs<\/code> \u0438\u0437 \u043a\u043e\u043c\u0430\u043d\u0434\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438 \u043f\u0440\u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0435 <code>forever<\/code>, \u043d\u043e \u0442\u0430\u043a\u0430\u044f \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0435\u0441\u0442\u044c, \u0435\u0441\u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0439 \u0444\u0430\u0439\u043b:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">{   \"uid\": \"app_es6\",   \"max\": 5,   \"spinSleepTime\": 1000,   \"minUptime\": 1000,   \"append\": true,   \"watch\": false,   \"script\": \"src\/app_es6.mjs\",   \"command\": \"node --experimental-modules\" }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0417\u0430\u043f\u0443\u0441\u043a \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0432 \u0442\u0430\u043a\u043e\u043c \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0435 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">$ forever start forever.es6.json ... $ forever list info:    Forever processes running data:        uid     command                     script          forever pid  id logfile                           uptime       data:    [0] app_es6 node --experimental-modules src\/app_es6.mjs 3972    3979    \/home\/ubuntu\/.forever\/app_es6.log 0:0:0:3.354 <\/code><\/pre>\n<p>  <\/p>\n<p>\u0412\u043e\u0442 \u0441\u0430\u043c\u0438 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u044b:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">$ ps -Af | grep es6 ubuntu    3972     1  0 12:01 ?        00:00:00 \/usr\/bin\/node \/usr\/lib\/node_modules\/forever\/bin\/monitor src\/app_es6.mjs ubuntu    3979  3972  0 12:01 ?        00:00:00 node --experimental-modules \/home\/ubuntu\/sof_es6_pm\/src\/app_es6.mjs<\/code><\/pre>\n<p>  <\/p>\n<p>\u041f\u0440\u0438 &#171;\u0443\u0431\u0438\u0439\u0441\u0442\u0432\u0435&#187; \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 (<code>PID 3979<\/code>) \u043c\u0435\u043d\u0435\u0434\u0436\u0435\u0440 \u0438\u0441\u043f\u0440\u0430\u0432\u043d\u043e \u043f\u043e\u0434\u043d\u0438\u043c\u0430\u0435\u0442 \u043d\u043e\u0432\u044b\u0439 (<code>PID 4013<\/code>):<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">$ kill -s SIGKILL 3979 ubuntu@vsf:~\/sof_es6_pm$ ps -Af | grep es6 ubuntu    3972     1  0 12:01 ?        00:00:00 \/usr\/bin\/node \/usr\/lib\/node_modules\/forever\/bin\/monitor src\/app_es6.mjs ubuntu    4013  3972  4 12:10 ?        00:00:00 node --experimental-modules \/home\/ubuntu\/sof_es6_pm\/src\/app_es6.mjs<\/code><\/pre>\n<p>  <\/p>\n<p><code>forever<\/code> \u043f\u0440\u0435\u043a\u0440\u0430\u0441\u043d\u043e \u0441\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441 \u0437\u0430\u043f\u0443\u0441\u043a\u043e\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0449\u0435\u0433\u043e ES6-\u043c\u043e\u0434\u0443\u043b\u0438, \u043d\u043e \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442 \u0432\u043e\u043f\u0440\u043e\u0441, \u0437\u0430\u0447\u0435\u043c \u0442\u044f\u043d\u0443\u0442\u044c \u043d\u0430 linux-\u0441\u0438\u0441\u0442\u0435\u043c\u044b <code>forever<\/code>, \u0435\u0441\u043b\u0438 \u043f\u043e\u0434\u043e\u0431\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u043c\u043e\u0436\u043d\u043e \u0434\u043e\u0431\u0438\u0442\u044c\u0441\u044f \u0438 \u0447\u0435\u0440\u0435\u0437 \u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0430 \u0441\u0430\u043c\u043e\u0439 \u041e\u0421?<\/p>\n<p>  <\/p>\n<h1 id=\"systemd\">systemd<\/h1>\n<p>  <\/p>\n<p><a href=\"https:\/\/habr.com\/ru\/company\/southbridge\/blog\/255845\/\">systemd<\/a> \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0441\u0435\u0440\u0432\u0438\u0441\u044b \u0432 linux-\u0441\u0440\u0435\u0434\u0435 \u0438 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438\u0445 \u0437\u0430\u043f\u0443\u0441\u043a, \u0432 \u0442\u043e\u043c \u0447\u0438\u0441\u043b\u0435 \u0438 \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0438\u0445 \u0432\u043d\u0435\u0437\u0430\u043f\u043d\u043e\u0433\u043e \u043f\u0430\u0434\u0435\u043d\u0438\u044f. \u0414\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c unit-\u0444\u0430\u0439\u043b \u0441 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435\u043c \u0441\u0435\u0440\u0432\u0438\u0441\u0430 (<code>.\/app_es6.service<\/code>):<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">[Unit] Description=Simple web server with ES6 modules. After=network.target  [Service] Type=simple Restart=always PIDFile=\/run\/app_es6.pid WorkingDirectory=\/home\/ubuntu\/sof_es6_pm ExecStart=\/usr\/bin\/nodejs --experimental-modules \/home\/ubuntu\/sof_es6_pm\/src\/app_es6.mjs  [Install] WantedBy=multi-user.target<\/code><\/pre>\n<p>  <\/p>\n<p>\u0438 \u0437\u0430\u043b\u0438\u043d\u043a\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u0432 \u043a\u0430\u0442\u0430\u043b\u043e\u0433 <code>\/etc\/systemd\/system<\/code> (\u0432 unit-\u0444\u0430\u0439\u043b\u0435 \u043f\u0443\u0442\u0438 \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u044b\u0442\u044c \u0430\u0431\u0441\u043e\u043b\u044e\u0442\u043d\u044b\u043c\u0438). \u0417\u0430 \u0440\u0435\u0441\u0442\u0430\u0440\u0442 \u0441\u0435\u0440\u0432\u0438\u0441\u0430 \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0435\u0433\u043e \u0432\u043d\u0435\u0437\u0430\u043f\u043d\u043e\u0433\u043e \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u0430 \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u043e\u043f\u0446\u0438\u044f:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">Restart=always<\/code><\/pre>\n<p>  <\/p>\n<p>\u0417\u0430\u043f\u0443\u0441\u043a \u0441\u0435\u0440\u0432\u0438\u0441\u0430 \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0442\u0430\u043a:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\"># systemctl start app_es6.service # systemctl status app_es6.service  \u25cf app_es6.service - Simple web server with ES6 modules.    Loaded: loaded (\/home\/ubuntu\/sof_es6_pm\/app_es6.service; linked; vendor preset: enabled)    Active: active (running) since Thu 2020-01-02 11:09:42 UTC; 9s ago  Main PID: 2184 (nodejs)     Tasks: 11 (limit: 4662)    CGroup: \/system.slice\/app_es6.service            \u2514\u25002184 \/usr\/bin\/nodejs --experimental-modules \/home\/ubuntu\/sof_es6_pm\/src\/app_es6.mjs  Jan 02 11:09:42 vsf systemd[1]: Started Simple web server with ES6 modules.. Jan 02 11:09:42 vsf nodejs[2184]: (node:2184) ExperimentalWarning: The ESM module loader is experimental. Jan 02 11:09:42 vsf nodejs[2184]: ES6 app listening on port 3000!<\/code><\/pre>\n<p>  <\/p>\n<p>\u041f\u0440\u0438 &#171;\u0443\u0431\u0438\u0439\u0441\u0442\u0432\u0435&#187; \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 (<code>PID 2184<\/code>) <code>systemd<\/code> \u0438\u0441\u043f\u0440\u0430\u0432\u043d\u043e \u043f\u043e\u0434\u043d\u0438\u043c\u0430\u0435\u0442 \u043d\u043e\u0432\u044b\u0439 (<code>PID 2233<\/code>):<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\"># ps -Af | grep app_es6 root      2184     1  0 11:09 ?        00:00:00 \/usr\/bin\/nodejs --experimental-modules \/home\/ubuntu\/sof_es6_pm\/src\/app_es6.mjs # kill -s SIGKILL 2184 # ps -Af | grep app_es6 root      2233     1  3 11:10 ?        00:00:00 \/usr\/bin\/nodejs --experimental-modules \/home\/ubuntu\/sof_es6_pm\/src\/app_es6.mjs<\/code><\/pre>\n<p>  <\/p>\n<p>\u0422.\u0435., <code>systemd<\/code> \u0434\u0435\u043b\u0430\u0435\u0442 \u0442\u043e \u0436\u0435 \u0441\u0430\u043c\u043e\u0435, \u0447\u0442\u043e \u0438 <code>forever<\/code>, \u043d\u043e \u043d\u0430 \u0431\u043e\u043b\u0435\u0435 \u0444\u0443\u043d\u0434\u0430\u043c\u0435\u043d\u0442\u0430\u043b\u044c\u043d\u043e\u043c \u0443\u0440\u043e\u0432\u043d\u0435.<\/p>\n<p>  <\/p>\n<h1 id=\"strongloop\">StrongLoop<\/h1>\n<p>  <\/p>\n<p>\u041f\u0440\u0438 \u043e\u0431\u0437\u043e\u0440\u0435 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u0432 \u0438\u043c\u043f\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0439 \u043c\u0435\u043d\u0435\u0434\u0436\u0435\u0440\u043e\u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432 \u0447\u0430\u0441\u0442\u043e \u0432\u0441\u043f\u043b\u044b\u0432\u0430\u0435\u0442 <a href=\"https:\/\/strong-pm.io\/\">StrongLoop<\/a>. \u041e\u0434\u043d\u0430\u043a\u043e <a href=\"https:\/\/www.npmtrends.com\/pm2-vs-strongloop-vs-forever\">\u043e\u0447\u0435\u043d\u044c \u0441\u0438\u043b\u044c\u043d\u043e \u043f\u043e\u0445\u043e\u0436\u0435<\/a>, \u0447\u0442\u043e \u044d\u0442\u043e\u0442 \u043f\u0440\u043e\u0435\u043a\u0442 \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u043b \u0440\u0430\u0437\u0432\u0438\u0432\u0430\u0442\u044c\u0441\u044f (\u043f\u043e\u0441\u043b\u0435\u0434\u043d\u044f\u044f \u0432\u0435\u0440\u0441\u0438\u044f 6.0.3 \u0432\u044b\u0448\u043b\u0430 <a href=\"https:\/\/www.npmjs.com\/package\/strongloop\">3 \u0433\u043e\u0434\u0430 \u043d\u0430\u0437\u0430\u0434<\/a>). \u041c\u043d\u0435 \u043d\u0435 \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u0435\u0433\u043e \u0434\u0430\u0436\u0435 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u043d\u0430 Ubuntu 18.04 \u0447\u0435\u0440\u0435\u0437 <code>npm<\/code>:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\"># npm install -g strongloop npm WARN deprecated swagger-ui@2.2.10: No longer maintained, please upgrade to swagger-ui@3. ... npm ERR! A complete log of this run can be found in: npm ERR!     \/root\/.npm\/_logs\/2020-01-02T11_25_15_473Z-debug.log<\/code><\/pre>\n<p>  <\/p>\n<p>\u0427\u0435\u0440\u0435\u0437 <code>yarn<\/code> \u043f\u0430\u043a\u0435\u0442 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043b\u0441\u044f, \u043d\u0435\u0441\u043c\u043e\u0442\u0440\u044f \u043d\u0430 \u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439 \u043e deprecated \u0432\u0435\u0440\u0441\u0438\u044f\u0445 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439 \u0438 \u043e\u0448\u0438\u0431\u043e\u043a \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438, \u0442\u0435\u043c \u043d\u0435 \u043c\u0435\u043d\u0435\u0435, \u043e\u0442 \u0438\u0437\u0443\u0447\u0435\u043d\u0438\u044f StronLoop&#8217;\u0430 \u044f \u043e\u0442\u043a\u0430\u0437\u0430\u043b\u0441\u044f.<\/p>\n<p>  <\/p>\n<h1 id=\"instrumenty-razrabotchika\">\u0418\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430<\/h1>\n<p>  <\/p>\n<p>\u041e\u0447\u0435\u043d\u044c \u0447\u0430\u0441\u0442\u043e \u0440\u044f\u0434\u043e\u043c \u0441 <code>pm2<\/code> \u0438 <code>forever<\/code> <a href=\"https:\/\/www.npmtrends.com\/pm2-vs-nodemon-vs-watch-vs-onchange\">\u0432\u0441\u0442\u0440\u0435\u0447\u0430\u044e\u0442\u0441\u044f<\/a> \u0442\u0430\u043a\u0438\u0435 \u043f\u0430\u043a\u0435\u0442\u044b, \u043a\u0430\u043a <a href=\"https:\/\/www.npmjs.com\/package\/nodemon\">nodemon<\/a>, <a href=\"https:\/\/www.npmjs.com\/package\/watch\">watch<\/a>, <a href=\"https:\/\/www.npmjs.com\/package\/onchange\">onchange<\/a>. \u042d\u0442\u0438 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b \u043d\u0435 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043c\u0435\u043d\u0435\u0434\u0436\u0435\u0440\u0430\u043c\u0438 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432, \u043d\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0442 \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u0442\u044c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0432 \u0444\u0430\u0439\u043b\u0430\u0445 \u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u043a\u043e\u043c\u0430\u043d\u0434\u044b, \u043f\u0440\u0438\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0435 \u043a \u044d\u0442\u0438\u043c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f\u043c (\u0432 \u0442\u043e\u043c \u0447\u0438\u0441\u043b\u0435, \u0438 \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435).<\/p>\n<p>  <\/p>\n<h1 id=\"rezyume\">\u0420\u0435\u0437\u044e\u043c\u0435<\/h1>\n<p>  <\/p>\n<p>\u041c\u0435\u043d\u0435\u0434\u0436\u0435\u0440 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432, \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0439 <code>pm2<\/code>, \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043e\u0447\u0435\u043d\u044c \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u043c \u0441\u0435\u0440\u0432\u0438\u0441\u043e\u043c \u0432 \u043c\u0438\u0440\u0435 \u0441\u0435\u0440\u0432\u0435\u0440\u043d\u043e\u0433\u043e JS. \u041d\u043e, \u043a \u0441\u043e\u0436\u0430\u043b\u0435\u043d\u0438\u044e, \u0441\u0430\u043c <code>pm2<\/code> \u043d\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 <code>nodejs<\/code>-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f (\u0432 \u0447\u0430\u0441\u0442\u043d\u043e\u0441\u0442\u0438 \u2014 \u0441 ES6-\u043c\u043e\u0434\u0443\u043b\u044f\u043c\u0438). \u0422\u0430\u043a \u043a\u0430\u043a \u044f \u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u043b\u044e\u0431\u043b\u044e \u0442\u0440\u0430\u043d\u0441\u043f\u0438\u043b\u044f\u0446\u0438\u044e, \u0442\u043e \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u043f\u0440\u0438\u0435\u043c\u043b\u0435\u043c\u044b\u043c \u043d\u0430 \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u043c\u0435\u043d\u0435\u0434\u0436\u0435\u0440\u043e\u043c \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432 \u0432 <code>nodejs<\/code> \u0434\u043b\u044f \u043c\u0435\u043d\u044f \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0442\u0440\u0430\u0434\u0438\u0446\u0438\u043e\u043d\u043d\u044b\u0439 <code>systemd<\/code> (\u0438\u043b\u0438 \u0435\u0433\u043e <a href=\"http:\/\/supervisord.org\/index.html\">\u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u044b<\/a>). \u041e\u0434\u043d\u0430\u043a\u043e \u044f \u0441 \u0440\u0430\u0434\u043e\u0441\u0442\u044c\u044e \u0431\u0443\u0434\u0443 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <code>pm2<\/code>, \u043a\u0430\u043a \u0442\u043e\u043b\u044c\u043a\u043e <code>pm2<\/code> \u0441\u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0442\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0441 ES6-\u043c\u043e\u0434\u0443\u043b\u044f\u043c\u0438.<\/p>\n<\/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\/482370\/\"> https:\/\/habr.com\/ru\/post\/482370\/<\/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\/482370\/\">\n<p>\u0412 \u043c\u0438\u0440\u0435 \u0441\u0435\u0440\u0432\u0435\u0440\u043d\u043e\u0433\u043e JavaScript&#8217;\u0430 \u044f \u2014 \u043d\u043e\u0432\u0438\u0447\u043e\u043a \u0441 \u0447\u0438\u0441\u0442\u044b\u043c, \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043d\u0435\u0437\u0430\u043c\u0443\u0442\u043d\u0451\u043d\u043d\u044b\u043c \u0440\u0430\u0437\u0443\u043c\u043e\u043c. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043a\u043e\u0433\u0434\u0430 \u044f \u0443\u0437\u043d\u0430\u043b \u043e \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043e\u0432\u0430\u043d\u0438\u0438 \u043c\u0435\u043d\u0435\u0434\u0436\u0435\u0440\u043e\u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432, \u0430 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e \u2014 \u043e <a href=\"https:\/\/habr.com\/ru\/post\/480670\/\">pm2<\/a>, \u0442\u043e \u0441\u0440\u0430\u0437\u0443 \u0436\u0435 \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u043b \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u044c \u0435\u0433\u043e \u0434\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u043a\u0430\u043a\u043e\u0433\u043e-\u043d\u0438\u0431\u0443\u0434\u044c \u043f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0435\u0433\u043e backend-\u0441\u0435\u0440\u0432\u0438\u0441\u0430 \u043d\u0430 <code>nodejs<\/code> \u0432 \u0446\u0435\u043b\u044f\u0445 \u0441\u0430\u043c\u043e\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044f. \u041c\u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u0438\u043c\u043f\u043e\u043d\u0438\u0440\u0443\u0435\u0442 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u043c\u043e\u0434\u0443\u043b\u0435\u0439 \u0432 JS-\u043a\u043e\u0434\u0435 \u0447\u0435\u0440\u0435\u0437 <code>import<\/code> (<a href=\"https:\/\/nodejs.org\/docs\/latest-v12.x\/api\/esm.html\">ES6 modules<\/a>), \u0442.\u043a. \u043e\u043d \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043e\u0434\u0438\u043d \u0438 \u0442\u043e\u0442 \u0436\u0435 \u043a\u043e\u0434 \u043a\u0430\u043a \u0432 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0435, \u0442\u0430\u043a \u0438 \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u043d\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u0435, \u0438 \u044f \u0437\u0430\u043f\u0438\u043b\u0438\u043b \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0441\u0435\u0440\u0432\u0438\u0441 \u0441 ES6-\u043c\u043e\u0434\u0443\u043b\u044f\u043c\u0438.<\/p>\n<p>  <\/p>\n<p>\u0415\u0441\u043b\u0438 \u0432\u043a\u0440\u0430\u0442\u0446\u0435, \u0442\u043e \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c ES6-\u0432\u0435\u0440\u0441\u0438\u044e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043f\u043e\u0434 <code>pm2<\/code> \u0443 \u043c\u0435\u043d\u044f \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c, \u0434\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0442\u0430\u043a\u0438\u0445 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439 \u043b\u0443\u0447\u0448\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043b\u0438\u0431\u043e <code>forever<\/code>, \u043b\u0438\u0431\u043e <code>systemd<\/code>. \u041f\u043e\u0434 \u043a\u0430\u0442\u043e\u043c \u2014 \u043e\u0442\u0447\u0451\u0442 \u043e \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430\u0445 \u0434\u043b\u044f \u0442\u0435\u0445, \u043a\u0442\u043e \u043b\u044e\u0431\u0438\u0442 \u0442\u0435\u043a\u0441\u0442\u044b \u043f\u043e\u0434\u043b\u0438\u043d\u0435\u0435.<\/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-296684","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/296684","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=296684"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/296684\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=296684"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=296684"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=296684"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}