{"componentChunkName":"component---src-templates-blog-post-js","path":"/nodejs/pm2/","result":{"data":{"site":{"siteMetadata":{"title":"아구몬","author":"[AGUMON]","siteUrl":"https://ljlm0402.netlify.com","comment":{"disqusShortName":"","utterances":"ljlm0402/tech-blog"},"sponsor":{"buyMeACoffeeId":""}}},"markdownRemark":{"id":"2e38b108-5413-5834-accd-fe974e1a23c0","excerpt":"💎 목차 설치를 하며 명령어 보며 생각 해보며 ⚙️ 설치를 하며 ⬆ 목차 😳 명령어 보며 ▸ pm2 -v pm2 버전 확인 ▸ pm2 start <id|name> 프로세스 실행 ▸ pm2 stop <id|name> 프로세스 중지 ▸ pm2 restart <id|name> 프로세스 재시작 ▸ pm2 delete <id|name> 프로세스 제거 ▸ pm2 list 프로세스 목록 ▸ pm2 show <id|name> 프로세스 상세 조회 ▸ pm2 log 프로세스 로그파일 확인 ▸ pm2 log…","html":"<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 590px; \"\n    >\n      <span\n    class=\"gatsby-resp-image-background-image\"\n    style=\"padding-bottom: 27.7027027027027%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAGCAYAAADDl76dAAAACXBIWXMAAAsSAAALEgHS3X78AAABhUlEQVQY002Rv0sCcRjG3xSM0/NO7/xxdx5HmQ4REWplZSeiixQRtKWB1GIOYhEaBC5B0NDYINFaUBCeLY31JzRUf0FDDUGetAXXc7U0fHjeB16e7/u+X9J7ZhmUwLpumJXc3bdCRA6/HFV4UWZBiROkA2iHF6U5XpAI9QQvyBfQNZDn/vqCYJf03qCW7Q22QVU3+o38vaU5iEK+sJZEQxzNW5wg73GiVEdwFZ5Qb0Db0CJ6xvBIGA/EUDcIQfugBZp697NdfLZU1sMd+UJaAQ06H4jI0FVg+xw4RfAKdB6hFdCCr8GXQZJ0Y7CDKRsIrGPlJlYecRElxegUSYkCBeJJYhlPjGXYmDxTJE4Ib3o5ESopmNDeYg26BL8MCgg0/9GnzNWb07KsofT5CzPbeXSnTh48x5blPATpsyc3gwNzvmCEDyg8TuFEmAuhDPCAYXtlDRNqv2qYtkYWLl9V1IpN9vZLyVy/qyCyePOh6t2+y+v1j/OiksLdJsEoJrNvncCnTf8Ao+x/6OhATdwAAAAASUVORK5CYII='); background-size: cover; display: block;\"\n  ></span>\n  <img\n        class=\"gatsby-resp-image-image\"\n        alt=\"logo\"\n        title=\"logo\"\n        src=\"/static/987dae32c2e2b9dc4b7fcfdaa34df6e1/fcda8/logo.png\"\n        srcset=\"/static/987dae32c2e2b9dc4b7fcfdaa34df6e1/12f09/logo.png 148w,\n/static/987dae32c2e2b9dc4b7fcfdaa34df6e1/e4a3f/logo.png 295w,\n/static/987dae32c2e2b9dc4b7fcfdaa34df6e1/fcda8/logo.png 590w,\n/static/987dae32c2e2b9dc4b7fcfdaa34df6e1/efc66/logo.png 885w,\n/static/987dae32c2e2b9dc4b7fcfdaa34df6e1/62a6a/logo.png 1122w\"\n        sizes=\"(max-width: 590px) 100vw, 590px\"\n        style=\"width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;\"\n        loading=\"lazy\"\n      />\n    </span></p>\n<center><strong style=\"color:#3EB1F3; font-size: 20px;\">노드 프로세스</strong>를 관리해주는 라이브러리</center>\n<h2 id=\"-목차\" style=\"position:relative;\"><a href=\"#-%EB%AA%A9%EC%B0%A8\" aria-label=\" 목차 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a><strong>💎 목차</strong></h2>\n<ul>\n<li><a href=\"#%EF%B8%8F-%EC%84%A4%EC%B9%98%EB%A5%BC-%ED%95%98%EB%A9%B0\">설치를 하며</a></li>\n<li><a href=\"#-%EB%AA%85%EB%A0%B9%EC%96%B4-%EB%B3%B4%EB%A9%B0\">명령어 보며</a></li>\n<li><a href=\"#-%EC%83%9D%EA%B0%81%ED%95%B4-%EB%B3%B4%EB%A9%B0\">생각 해보며</a></li>\n</ul>\n<h2 id=\"️-설치를-하며\" style=\"position:relative;\"><a href=\"#%EF%B8%8F-%EC%84%A4%EC%B9%98%EB%A5%BC-%ED%95%98%EB%A9%B0\" aria-label=\"️ 설치를 하며 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a><strong>⚙️ 설치를 하며</strong></h2>\n<div class=\"gatsby-highlight\" data-language=\"sh\"><pre class=\"language-sh\"><code class=\"language-sh\">$ npm install pm2 -g</code></pre></div>\n<br />\n<p><strong><a href=\"#-%EB%AA%A9%EC%B0%A8\">⬆ 목차</a></strong></p>\n<hr />\n<h2 id=\"-명령어-보며\" style=\"position:relative;\"><a href=\"#-%EB%AA%85%EB%A0%B9%EC%96%B4-%EB%B3%B4%EB%A9%B0\" aria-label=\" 명령어 보며 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a><strong>😳 명령어 보며</strong></h2>\n<h3 id=\"▸-pm2--v\" style=\"position:relative;\"><a href=\"#%E2%96%B8-pm2--v\" aria-label=\"▸ pm2  v permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>▸ pm2 -v</h3>\n<div class=\"gatsby-highlight\" data-language=\"sh\"><pre class=\"language-sh\"><code class=\"language-sh\">$ pm2 -v\n3.5.1</code></pre></div>\n<p>pm2 버전 확인</p>\n<br />\n<hr />\n<h3 id=\"▸-pm2-start-idname\" style=\"position:relative;\"><a href=\"#%E2%96%B8-pm2-start-idname\" aria-label=\"▸ pm2 start idname permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>▸ pm2 start &#x3C;id|name></h3>\n<div class=\"gatsby-highlight\" data-language=\"sh\"><pre class=\"language-sh\"><code class=\"language-sh\">$ pm2 start ./bin/www\n[PM2] Starting /Users/apple/Desktop/pm2/bin/www in fork_mode (1 instance)\n[PM2] Done.\n┌──────────┬────┬─────────┬──────┬──────┬────────┬─────────┬────────┬─────┬──────────┬───────┬──────────┐\n│ App name │ id │ version │ mode │ pid  │ status │ restart │ uptime │ cpu │ mem      │ user  │ watching │\n├──────────┼────┼─────────┼──────┼──────┼────────┼─────────┼────────┼─────┼──────────┼───────┼──────────┤\n│ www      │ 0  │ 0.0.0   │ fork │ 8369 │ online │ 0       │ 0s     │ 0%  │ 9.2 MB   │ apple │ disabled │\n└──────────┴────┴─────────┴──────┴──────┴────────┴─────────┴────────┴─────┴──────────┴───────┴──────────┘</code></pre></div>\n<p>프로세스 실행</p>\n<br />\n<hr />\n<h3 id=\"▸-pm2-stop-idname\" style=\"position:relative;\"><a href=\"#%E2%96%B8-pm2-stop-idname\" aria-label=\"▸ pm2 stop idname permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>▸ pm2 stop &#x3C;id|name></h3>\n<div class=\"gatsby-highlight\" data-language=\"sh\"><pre class=\"language-sh\"><code class=\"language-sh\">$ pm2 stop www\n[PM2] Applying action stopProcessId on app [www](ids: 0)\n[PM2] [www](0) ✓\n┌──────────┬────┬─────────┬──────┬─────┬─────────┬─────────┬────────┬─────┬────────┬───────┬──────────┐\n│ App name │ id │ version │ mode │ pid │ status  │ restart │ uptime │ cpu │ mem    │ user  │ watching │\n├──────────┼────┼─────────┼──────┼─────┼─────────┼─────────┼────────┼─────┼────────┼───────┼──────────┤\n│ www      │ 0  │ 0.0.0   │ fork │ 0   │ stopped │ 0       │ 0      │ 0%  │ 0 B    │ apple │ disabled │\n└──────────┴────┴─────────┴──────┴─────┴─────────┴─────────┴────────┴─────┴────────┴───────┴──────────┘</code></pre></div>\n<p>프로세스 중지</p>\n<br />\n<hr />\n<h3 id=\"▸-pm2-restart-idname\" style=\"position:relative;\"><a href=\"#%E2%96%B8-pm2-restart-idname\" aria-label=\"▸ pm2 restart idname permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>▸ pm2 restart &#x3C;id|name></h3>\n<div class=\"gatsby-highlight\" data-language=\"sh\"><pre class=\"language-sh\"><code class=\"language-sh\">$ pm2 restart www\nUse --update-env to update environment variables\n[PM2] Applying action restartProcessId on app [www](ids: 0)\n[PM2] [www](0) ✓\n┌──────────┬────┬─────────┬──────┬──────┬────────┬─────────┬────────┬─────┬──────────┬───────┬──────────┐\n│ App name │ id │ version │ mode │ pid  │ status │ restart │ uptime │ cpu │ mem      │ user  │ watching │\n├──────────┼────┼─────────┼──────┼──────┼────────┼─────────┼────────┼─────┼──────────┼───────┼──────────┤\n│ www      │ 0  │ 0.0.0   │ fork │ 8477 │ online │ 1       │ 0s     │ 0%  │ 6.7 MB   │ apple │ disabled │\n└──────────┴────┴─────────┴──────┴──────┴────────┴─────────┴────────┴─────┴──────────┴───────┴──────────┘</code></pre></div>\n<p>프로세스 재시작</p>\n<br />\n<hr />\n<h3 id=\"▸-pm2-delete-idname\" style=\"position:relative;\"><a href=\"#%E2%96%B8-pm2-delete-idname\" aria-label=\"▸ pm2 delete idname permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>▸ pm2 delete &#x3C;id|name></h3>\n<div class=\"gatsby-highlight\" data-language=\"sh\"><pre class=\"language-sh\"><code class=\"language-sh\">$ pm2 delete www\n[PM2] Applying action deleteProcessId on app [www](ids: 0)\n[PM2] [www](0) ✓\n┌──────────┬────┬─────────┬──────┬─────┬────────┬─────────┬────────┬─────┬─────┬──────┬──────────┐\n│ App name │ id │ version │ mode │ pid │ status │ restart │ uptime │ cpu │ mem │ user │ watching │\n└──────────┴────┴─────────┴──────┴─────┴────────┴─────────┴────────┴─────┴─────┴──────┴──────────┘</code></pre></div>\n<p>프로세스 제거</p>\n<br />\n<hr />\n<h3 id=\"▸-pm2-list\" style=\"position:relative;\"><a href=\"#%E2%96%B8-pm2-list\" aria-label=\"▸ pm2 list permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>▸ pm2 list</h3>\n<div class=\"gatsby-highlight\" data-language=\"sh\"><pre class=\"language-sh\"><code class=\"language-sh\">$ pm2 list\n┌──────────┬────┬─────────┬──────┬──────┬────────┬─────────┬────────┬──────┬───────────┬───────┬──────────┐\n│ App name │ id │ version │ mode │ pid  │ status │ restart │ uptime │ cpu  │ mem       │ user  │ watching │\n├──────────┼────┼─────────┼──────┼──────┼────────┼─────────┼────────┼──────┼───────────┼───────┼──────────┤\n│ www      │ 0  │ 0.0.0   │ fork │ 8553 │ online │ 2       │ 26s    │ 0.1% │ 37.4 MB   │ apple │ disabled │\n└──────────┴────┴─────────┴──────┴──────┴────────┴─────────┴────────┴──────┴───────────┴───────┴──────────┘</code></pre></div>\n<p>프로세스 목록</p>\n<br />\n<hr />\n<h3 id=\"▸-pm2-show-idname\" style=\"position:relative;\"><a href=\"#%E2%96%B8-pm2-show-idname\" aria-label=\"▸ pm2 show idname permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>▸ pm2 show &#x3C;id|name></h3>\n<div class=\"gatsby-highlight\" data-language=\"sh\"><pre class=\"language-sh\"><code class=\"language-sh\">$ pm2 show www\n Describing process with id 0 - name www\n┌───────────────────┬──────────────────────────────────────┐\n│ status            │ online                               │\n│ name              │ www                                  │\n│ version           │ 0.0.0                                │\n│ restarts          │ 2                                    │\n│ uptime            │ 58s                                  │\n│ script path       │ /Users/apple/Desktop/pm2/bin/www     │\n│ script args       │ N/A                                  │\n│ error log path    │ /Users/apple/.pm2/logs/www-error.log │\n│ out log path      │ /Users/apple/.pm2/logs/www-out.log   │\n│ pid path          │ /Users/apple/.pm2/pids/www-0.pid     │\n│ interpreter       │ node                                 │\n│ interpreter args  │ N/A                                  │\n│ script id         │ 0                                    │\n│ exec cwd          │ /Users/apple/Desktop/pm2             │\n│ exec mode         │ fork_mode                            │\n│ node.js version   │ 10.16.0                              │\n│ node env          │ N/A                                  │\n│ watch &amp; reload    │ ✘                                    │\n│ unstable restarts │ 0                                    │\n│ created at        │ 2019-09-11T05:44:28.964Z             │\n└───────────────────┴──────────────────────────────────────┘\n Actions available\n┌────────────────────────┐\n│ km:heapdump            │\n│ km:cpu:profiling:start │\n│ km:cpu:profiling:stop  │\n│ km:heap:sampling:start │\n│ km:heap:sampling:stop  │\n└────────────────────────┘\n Trigger via: pm2 trigger www &lt;action_name&gt;\n\n Code metrics value\n┌────────────────────────┬───────────┐\n│ Heap Size              │ 14.73 MiB │\n│ Heap Usage             │ 66.85 %   │\n│ Used Heap Size         │ 9.85 MiB  │\n│ Active requests        │ 0         │\n│ Active handles         │ 4         │\n│ Event Loop Latency     │ 2.22 ms   │\n│ Event Loop Latency p95 │ 5.70 ms   │\n└────────────────────────┴───────────┘\n Divergent env variables from local env\n\n\n Add your own code metrics: http://bit.ly/code-metrics\n Use `pm2 logs www [--lines 1000]` to display logs\n Use `pm2 env 0` to display environement variables\n Use `pm2 monit` to monitor CPU and Memory usage www</code></pre></div>\n<p>프로세스 상세 조회</p>\n<br />\n<hr />\n<h3 id=\"▸-pm2-log\" style=\"position:relative;\"><a href=\"#%E2%96%B8-pm2-log\" aria-label=\"▸ pm2 log permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>▸ pm2 log</h3>\n<div class=\"gatsby-highlight\" data-language=\"sh\"><pre class=\"language-sh\"><code class=\"language-sh\">$ pm2 log\n[TAILING] Tailing last 15 lines for [all] processes (change the value with --lines option)\n/Users/apple/.pm2/pm2.log last 15 lines:\nPM2        | 2019-09-11T14:42:42: PM2 log: App [www:0] exited with code [0] via signal [SIGINT]\nPM2        | 2019-09-11T14:42:42: PM2 log: pid=8369 msg=process killed\nPM2        | 2019-09-11T14:43:39: PM2 log: App [www:0] starting in -fork mode-\nPM2        | 2019-09-11T14:43:39: PM2 log: App [www:0] online\nPM2        | 2019-09-11T14:43:45: PM2 log: Stopping app:www id:0\nPM2        | 2019-09-11T14:43:45: PM2 log: App [www:0] exited with code [0] via signal [SIGINT]\nPM2        | 2019-09-11T14:43:45: PM2 log: pid=8468 msg=process killed\nPM2        | 2019-09-11T14:43:45: PM2 log: App [www:0] starting in -fork mode-\nPM2        | 2019-09-11T14:43:45: PM2 log: App [www:0] online\nPM2        | 2019-09-11T14:44:28: PM2 log: Process 0 in a stopped status, starting it\nPM2        | 2019-09-11T14:44:28: PM2 log: Stopping app:www id:0\nPM2        | 2019-09-11T14:44:28: PM2 log: App [www:0] exited with code [0] via signal [SIGINT]\nPM2        | 2019-09-11T14:44:29: PM2 log: pid=8477 msg=process killed\nPM2        | 2019-09-11T14:44:29: PM2 log: App [www:0] starting in -fork mode-\nPM2        | 2019-09-11T14:44:29: PM2 log: App [www:0] online\n\n/Users/apple/.pm2/logs/www-out.log last 15 lines:\n/Users/apple/.pm2/logs/www-error.log last 15 lines:</code></pre></div>\n<p>프로세스 로그파일 확인</p>\n<br />\n<hr />\n<h3 id=\"▸-pm2-log-idname\" style=\"position:relative;\"><a href=\"#%E2%96%B8-pm2-log-idname\" aria-label=\"▸ pm2 log idname permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>▸ pm2 log &#x3C;id|name></h3>\n<div class=\"gatsby-highlight\" data-language=\"sh\"><pre class=\"language-sh\"><code class=\"language-sh\">$ pm2 log www\n[TAILING] Tailing last 15 lines for [www] process (change the value with --lines option)\n/Users/apple/.pm2/logs/www-out.log last 15 lines:\n/Users/apple/.pm2/logs/www-error.log last 15 lines:</code></pre></div>\n<p>특정 프로세스의 로그파일 확인</p>\n<br />\n<hr />\n<h3 id=\"▸-pm2-flush\" style=\"position:relative;\"><a href=\"#%E2%96%B8-pm2-flush\" aria-label=\"▸ pm2 flush permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>▸ pm2 flush</h3>\n<div class=\"gatsby-highlight\" data-language=\"sh\"><pre class=\"language-sh\"><code class=\"language-sh\">$ pm2 flush\n[PM2] Flushing /Users/apple/.pm2/pm2.log\n[PM2] Flushing:\n[PM2] /Users/apple/.pm2/logs/www-out.log\n[PM2] /Users/apple/.pm2/logs/www-error.log\n[PM2] Logs flushed</code></pre></div>\n<p>로그파일 삭제</p>\n<br />\n<hr />\n<h3 id=\"▸-pm2-monit\" style=\"position:relative;\"><a href=\"#%E2%96%B8-pm2-monit\" aria-label=\"▸ pm2 monit permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>▸ pm2 monit</h3>\n<div class=\"gatsby-highlight\" data-language=\"sh\"><pre class=\"language-sh\"><code class=\"language-sh\">┌─ Process list ──────────────────────────────────────┐┌─ Global Logs ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐\n│[ 0] www            Mem:  30 MB    CPU:  0 %  online ││                                                                                                                                │\n│                                                     ││                                                                                                                                │\n│                                                     ││                                                                                                                                │\n│                                                     ││                                                                                                                                │\n│                                                     ││                                                                                                                                │\n│                                                     ││                                                                                                                                │\n│                                                     ││                                                                                                                                │\n│                                                     ││                                                                                                                                │\n│                                                     ││                                                                                                                                │\n│                                                     ││                                                                                                                                │\n│                                                     ││                                                                                                                                │\n│                                                     ││                                                                                                                                │\n│                                                     ││                                                                                                                                │\n│                                                     ││                                                                                                                                │\n│                                                     ││                                                                                                                                │\n│                                                     ││                                                                                                                                │\n│                                                     ││                                                                                                                                │\n│                                                     ││                                                                                                                                │\n│                                                     ││                                                                                                                                │\n│                                                     ││                                                                                                                                │\n│                                                     ││                                                                                                                                │\n│                                                     ││                                                                                                                                │\n│                                                     ││                                                                                                                                │\n│                                                     ││                                                                                                                                │\n│                                                     ││                                                                                                                                │\n│                                                     ││                                                                                                                                │\n│                                                     ││                                                                                                                                │\n│                                                     ││                                                                                                                                │\n│                                                     ││                                                                                                                                │\n│                                                     ││                                                                                                                                │\n│                                                     ││                                                                                                                                │\n│                                                     ││                                                                                                                                │\n│                                                     ││                                                                                                                                │\n└─────────────────────────────────────────────────────┘└────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘\n┌─ Custom metrics (http://bit.ly/code-metrics) ───────┐┌─ Metadata ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐\n│ Heap Size                                    13.23  ││ App Name              www                                                                                                      │\n│ Heap Usage                                   66.42  ││ Version               0.0.0                                                                                                    │\n│ Used Heap Size                                8.79  ││ Restarts              2                                                                                                        │\n│ Active requests                                  0  ││ Uptime                3m                                                                                                       │\n│ Active handles                                   4  ││ Script path           /Users/apple/Desktop/pm2/bin/www                                                                         │\n│ Event Loop Latency                            2.13  ││ Script args           N/A                                                                                                      │\n│ Event Loop Latency p95                        5.54  ││ Interpreter           node                                                                                                     │\n│                                                     ││ Interpreter args      N/A                                                                                                      │\n│                                                     ││ Exec mode             fork                                                                                                     │\n│                                                     ││ Node.js version       10.16.0                                                                                                  │\n│                                                     ││ watch &amp; reload        ✘                                                                                                        │\n└─────────────────────────────────────────────────────┘└────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘\n\n left/right: switch boards | up/down/mouse: scroll | Ctrl-C: exit                                                                                To go further check out https://pm2.io/</code></pre></div>\n<p>프로세스 실시간 모니터링</p>\n<br />\n<p><strong><a href=\"#-%EB%AA%A9%EC%B0%A8\">⬆ 목차</a></strong></p>\n<hr />\n<h2 id=\"-생각해-보며\" style=\"position:relative;\"><a href=\"#-%EC%83%9D%EA%B0%81%ED%95%B4-%EB%B3%B4%EB%A9%B0\" aria-label=\" 생각해 보며 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a><strong>🤔 생각해 보며</strong></h2>\n<h3 id=\"▸-cluster-mode\" style=\"position:relative;\"><a href=\"#%E2%96%B8-cluster-mode\" aria-label=\"▸ cluster mode permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>▸ Cluster Mode</h3>\n<div class=\"gatsby-highlight\" data-language=\"sh\"><pre class=\"language-sh\"><code class=\"language-sh\">$ pm2 start ./bin/www -i 2\n[PM2] Starting /Users/apple/Desktop/pm2/bin/www in cluster_mode (2 instances)\n[PM2] Done.\n┌──────────┬────┬─────────┬─────────┬──────┬────────┬─────────┬────────┬─────┬───────────┬───────┬──────────┐\n│ App name │ id │ version │ mode    │ pid  │ status │ restart │ uptime │ cpu │ mem       │ user  │ watching │\n├──────────┼────┼─────────┼─────────┼──────┼────────┼─────────┼────────┼─────┼───────────┼───────┼──────────┤\n│ www      │ 0  │ 0.0.0   │ cluster │ 8888 │ online │ 0       │ 0s     │ 0%  │ 32.7 MB   │ apple │ disabled │\n│ www      │ 1  │ 0.0.0   │ cluster │ 8889 │ online │ 0       │ 0s     │ 0%  │ 25.2 MB   │ apple │ disabled │\n└──────────┴────┴─────────┴─────────┴──────┴────────┴─────────┴────────┴─────┴───────────┴───────┴──────────┘</code></pre></div>\n<p>클러스터 모드로 CPU를 최대한 활용</p>\n<p><code class=\"language-text\">-i</code> 옵션은 클러스터 모드로 실행하며 뒤에 인스턴스 개수를 지정 가능</p>\n<p><code class=\"language-text\">0</code>을 지정할 경우 사용 가능한 CPU 개수만큼 실행</p>\n<br />\n<hr />\n<h4 id=\"▸-pm2-reload-idname\" style=\"position:relative;\"><a href=\"#%E2%96%B8-pm2-reload-idname\" aria-label=\"▸ pm2 reload idname permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>▸ pm2 reload &#x3C;id|name></h4>\n<div class=\"gatsby-highlight\" data-language=\"sh\"><pre class=\"language-sh\"><code class=\"language-sh\">$ pm2 reload www\nUse --update-env to update environment variables\n[PM2] Applying action reloadProcessId on app [www](ids: 0,1)\n[PM2] [www](0) ✓\n[PM2] [www](1) ✓</code></pre></div>\n<p>클러스터 모드에 사용할 경우 다운타임 없이 서버를 재기동할 수 있다.</p>\n<br />\n<hr />\n<h3 id=\"▸-ecosystem-file\" style=\"position:relative;\"><a href=\"#%E2%96%B8-ecosystem-file\" aria-label=\"▸ ecosystem file permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>▸ Ecosystem File</h3>\n<div class=\"gatsby-highlight\" data-language=\"sh\"><pre class=\"language-sh\"><code class=\"language-sh\">$ pm2 ecosystem</code></pre></div>\n<p>pm2 설정 파일 생성</p>\n<br />\n<p><strong>ecosystem.cofing.js</strong></p>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 590px; \"\n    >\n      <span\n    class=\"gatsby-resp-image-background-image\"\n    style=\"padding-bottom: 76.35135135135135%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAPCAYAAADkmO9VAAAACXBIWXMAAAsTAAALEwEAmpwYAAAB3klEQVQ4y52US27aUBSGvYCAQCBFPMy1MWCMbQwYN2kHGVSq1CUg2AMDHhKwgWYjLIB9AOMAKTBA4inxFAz/+jqJkhaV4g4+Hcm6/+dz7GMzu90Oh8MBp9MJx48cj1dDs9Sx3W7BbDYbTKdT9J6e0O/1Xuj3LQaDwVXQs5PJBLQ55ufzM348PoIk4kh/+Qz1zkAylYKiKJAk6Z/Qc6FQCMViEfv9Hky320WpVMIt4SFndAQJC3/QJBCAz+9HwKyXYFkWLpcL+Xwey+USTKfTQaVSgcvphJa9RzJjIBWPQIwKEMK8dfdL8DwPr9eLQqGA+Xz+LnTc3JgjP8D4+h1K2kBGlaGK0dcg+1chx3HweDznQqfTATmdRfrhGySzipGw1SHLhqyxaPitXil0Qk6mYGR1SOa4YY5AFMKIRwRwhLxL7QgVNYmsriOjZyGrGpR4zOz0d6GtDqWEjPtPBgzDgJLUoCVEaJIIgeftCcvlMtxuN2KxKNhgwCJorgQxA4Rcfstnwna7jWq1Cp/PB0EQEDLHI6+8hciHa39ytjZUSBfb4XBYi0rFdqAZ+rhyudyLkH6LrVYLtVoNjUYD9XrdNjTbbDaxWCzArFYrzGYzjMdjDIfD/2I0Glk/mPV6jV/3+oNvHgyjWgAAAABJRU5ErkJggg=='); background-size: cover; display: block;\"\n  ></span>\n  <img\n        class=\"gatsby-resp-image-image\"\n        alt=\"1\"\n        title=\"1\"\n        src=\"/static/d33cf109d96a52ee63680ba47d36e189/fcda8/1.png\"\n        srcset=\"/static/d33cf109d96a52ee63680ba47d36e189/12f09/1.png 148w,\n/static/d33cf109d96a52ee63680ba47d36e189/e4a3f/1.png 295w,\n/static/d33cf109d96a52ee63680ba47d36e189/fcda8/1.png 590w,\n/static/d33cf109d96a52ee63680ba47d36e189/efc66/1.png 885w,\n/static/d33cf109d96a52ee63680ba47d36e189/c83ae/1.png 1180w,\n/static/d33cf109d96a52ee63680ba47d36e189/9cea8/1.png 1278w\"\n        sizes=\"(max-width: 590px) 100vw, 590px\"\n        style=\"width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;\"\n        loading=\"lazy\"\n      />\n    </span>\n<br /></p>\n<p><code class=\"language-text\">name</code> 실행한 프로세스 이름</p>\n<p><code class=\"language-text\">script</code> 실행할 파일 경로</p>\n<p><code class=\"language-text\">watch</code> 파일 변경시 자동으로 재실행 여부 (true, false)</p>\n<p><code class=\"language-text\">exec_mode</code> 실행 모드 (cluster, fork)</p>\n<p><code class=\"language-text\">instances</code> cluster로 실행시 인스턴스 개수</p>\n<p><code class=\"language-text\">env</code> 환경변수로 PORT, NODE_ENV 같은 precess.env.{} 설정</p>\n<br />\n<div class=\"gatsby-highlight\" data-language=\"sh\"><pre class=\"language-sh\"><code class=\"language-sh\"># NODE_ENV=production\n$ pm2 start ecosystem.cofing.js\n\n# NODE_ENV=development\n$ pm2 start ecosystem.cofing.js --env development</code></pre></div>\n<br />\n<p><strong><a href=\"#-%EB%AA%A9%EC%B0%A8\">⬆ 목차</a></strong></p>\n<hr />\n<br />\n<blockquote>\n<p>출처</p>\n<p><a href=\"https://github.com/bynodejs/pm2\" target=\"_blank\">GitHub > pm2</a></p>\n</blockquote>\n<h1 id=\"여러분의-댓글이-큰힘이-됩니다-๑̀ㅂ́و✧\" style=\"position:relative;\"><a href=\"#%EC%97%AC%EB%9F%AC%EB%B6%84%EC%9D%98-%EB%8C%93%EA%B8%80%EC%9D%B4-%ED%81%B0%ED%9E%98%EC%9D%B4-%EB%90%A9%EB%8B%88%EB%8B%A4-%E0%B9%91%CC%80%E3%85%82%CC%81%D9%88%E2%9C%A7\" aria-label=\"여러분의 댓글이 큰힘이 됩니다 ๑̀ㅂ́و✧ permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>여러분의 댓글이 큰힘이 됩니다. (๑•̀ㅂ•́)و✧</h1>","frontmatter":{"title":" 프로세스 관리 ⚙️ ▻ pm2 ","date":"September 11, 2019"}}},"pageContext":{"slug":"/nodejs/pm2/","previous":{"fields":{"slug":"/nodejs/dotenv/"},"frontmatter":{"title":" 환경변수 관리 🔒 ▻ dotenv ","category":"Node Js"}},"next":{"fields":{"slug":"/nodejs/nodemailer/"},"frontmatter":{"title":" 이메일 📬 ▻ nodemailer ","category":"Node Js"}}}},"staticQueryHashes":["3128451518","3956431471"]}