{"id":1987,"date":"2022-04-16T15:11:10","date_gmt":"2022-04-16T06:11:10","guid":{"rendered":"https:\/\/blog.wsd.sh\/?p=1987"},"modified":"2022-04-16T16:34:45","modified_gmt":"2022-04-16T07:34:45","slug":"centos-stram-9pm2%e3%81%ae%e8%87%aa%e5%8b%95%e8%b5%b7%e5%8b%95","status":"publish","type":"post","link":"https:\/\/blog.wsd.sh\/?p=1987","title":{"rendered":"<small> CentOS stram 9:pm2 \u306e\u81ea\u52d5\u8d77\u52d5<\/small>"},"content":{"rendered":"<p>1. \u74b0\u5883<br \/>\n\u30fbCentOS stram 9<br \/>\n2. pm2\u306e\u81ea\u52d5\u8d77\u52d5<br \/>\n(1) pm2\u3067\u305d\u308c\u305e\u308c\u306e\u30b5\u30fc\u30d3\u30b9\u3092\u8d77\u52d5\u3055\u305b\u3066\u304a\u304f<\/p>\n<pre>\r\n# cd \/opt\/ProvateInvocie\/166S\r\n# pm2 index.js --name 166S\r\n# cd \/opt\/ProvateInvocie\/166C\r\n# pm2 index.js --name 166C\r\n# pm2 list\r\nlqqqqwqqqqqqqqqqqqqqqqqqqqwqqqqqqqqqqwqqqqqqwqqqqqqqqqqqwqqqqqqqqqqwqqqqqqqqqqk\r\nx id x name               x mode     x ?    x status    x cpu      x memory   x\r\ntqqqqnqqqqqqqqqqqqqqqqqqqqnqqqqqqqqqqnqqqqqqnqqqqqqqqqqqnqqqqqqqqqqnqqqqqqqqqqu\r\nx 1  x 166C               x fork     x 0    x online    x 0%       x 63.5mb   x\r\nx 2  x 166S               x fork     x 0    x online    x 0%       x 66.5mb   x\r\nmqqqqvqqqqqqqqqqqqqqqqqqqqvqqqqqqqqqqvqqqqqqvqqqqqqqqqqqvqqqqqqqqqqvqqqqqqqqqqj\r\n<\/pre>\n<p>(2) PM2\u8d77\u52d5\u30b9\u30af\u30ea\u30d7\u30c8<br \/>\n\u30fbpm2 save<br \/>\n\u30fb~\/.pm2\/dump.pm2\u306b\u4f5c\u6210\u3055\u308c\u308b<\/p>\n<pre>\r\n# pm2 save\r\n# ls -l ~\/.pm2\/dump.pm2\r\n-rw-r--r--. 1 root root 19972 Apr 16 14:05 \/root\/.pm2\/dump.pm2\r\n<\/pre>\n<p>3. pm2\u3067\u30b5\u30fc\u30d3\u30b9\u306e\u4f5c\u6210\u3068\u78ba\u8a8d<br \/>\n\u30fbpm2 startup centos<\/p>\n<pre>\r\n# pm2 startup centos\r\n# ls \/etc\/systemd\/system\/pm2-root.service\r\n# cat \/etc\/systemd\/system\/pm2-root.service\r\n[Unit]\r\nDescription=PM2 process manager\r\nDocumentation=https:\/\/pm2.keymetrics.io\/\r\nAfter=network.target\r\n\r\n[Service]\r\nType=forking\r\nUser=root\r\nLimitNOFILE=infinity\r\nLimitNPROC=infinity\r\nLimitCORE=infinity\r\nEnvironment=PATH=\/root\/.local\/bin:\/root\/bin:\/usr\/local\/sbin:\/usr\/local\/bin:\/usr\/sbin:\/usr\/bin:\/bin:\/usr\/local\/sbin:\/usr\/local\/bin:\/usr\/sbin:\/usr\/bin\r\nEnvironment=PM2_HOME=\/root\/.pm2\r\nPIDFile=\/root\/.pm2\/pm2.pid\r\nRestart=on-failure\r\n\r\nExecStart=\/usr\/local\/lib\/node_modules\/pm2\/bin\/pm2 resurrect\r\nExecReload=\/usr\/local\/lib\/node_modules\/pm2\/bin\/pm2 reload all\r\nExecStop=\/usr\/local\/lib\/node_modules\/pm2\/bin\/pm2 kill\r\n\r\n[Install]\r\nWantedBy=multi-user.target\r\n[root@localhost 166C]#\r\n<\/pre>\n<p>4. \u6ce8\u610f<br \/>\n\u65b0\u3057\u3044Node.js\u30d0\u30fc\u30b8\u30e7\u30f3\u306b\u30a2\u30c3\u30d7\u30b0\u30ec\u30fc\u30c9\u3059\u308b\u5834\u5408\u306f\u3001PM2\u8d77\u52d5\u30b9\u30af\u30ea\u30d7\u30c8\u3092\u66f4\u65b0\u3059\u308b\u5fc5\u8981\u304c\u3042\u308b\u3002<\/p>\n<pre>\r\n# pm2 unstartup\r\n# pm2 startup \r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>1. \u74b0\u5883 \u30fbCentOS stram 9 2. pm2\u306e\u81ea\u52d5\u8d77\u52d5 (1) pm2\u3067\u305d\u308c\u305e\u308c\u306e\u30b5\u30fc\u30d3\u30b9\u3092\u8d77\u52d5\u3055\u305b\u3066\u304a\u304f # cd \/opt\/ProvateInvocie\/166S # pm2 index.js &#8211;nam&#8230;<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_mi_skip_tracking":false},"categories":[1],"tags":[],"_links":{"self":[{"href":"https:\/\/blog.wsd.sh\/index.php?rest_route=\/wp\/v2\/posts\/1987"}],"collection":[{"href":"https:\/\/blog.wsd.sh\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.wsd.sh\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.wsd.sh\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.wsd.sh\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1987"}],"version-history":[{"count":5,"href":"https:\/\/blog.wsd.sh\/index.php?rest_route=\/wp\/v2\/posts\/1987\/revisions"}],"predecessor-version":[{"id":1994,"href":"https:\/\/blog.wsd.sh\/index.php?rest_route=\/wp\/v2\/posts\/1987\/revisions\/1994"}],"wp:attachment":[{"href":"https:\/\/blog.wsd.sh\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1987"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.wsd.sh\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1987"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.wsd.sh\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1987"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}