├── .drone.yml.bkp ├── .gitignore ├── .stylelintrc ├── CNAME ├── Dockerfile ├── Gemfile ├── README.md ├── SETUP.md ├── _config.yml ├── _data ├── sidebar-en.yml └── sidebar-zh.yml ├── _includes ├── edit-page │ ├── edit-page-en.html │ └── edit-page-zh.html ├── footer │ ├── footer-en.html │ └── footer-zh.html ├── head.html ├── header │ ├── header-en.html │ └── header-zh.html ├── meta-footer.html ├── sidebar.html └── sitemapxml.html ├── _layouts ├── home.html └── page.html ├── _sass ├── button.scss ├── code.scss ├── edit-page.scss ├── faq.scss ├── footer.scss ├── gitalk.scss ├── header.scss ├── homepage.scss ├── layout.scss ├── main.scss ├── markdown.scss ├── mobile.scss ├── print-layout.scss ├── prism.scss └── sidebar.scss ├── css ├── main.scss └── normalize.css ├── en ├── enterprise │ ├── collector │ │ ├── go.md │ │ ├── overview.md │ │ ├── pm2.md │ │ ├── prometheus.md │ │ └── standalone.md │ ├── frontend-monitoring │ │ ├── install.md │ │ ├── overview.md │ │ └── snippet-api.md │ ├── guides │ │ ├── alerting.md │ │ ├── dashboard.md │ │ ├── distributed-tracing.md │ │ ├── log.md │ │ ├── profiling.md │ │ ├── transaction-tracing.md │ │ └── webchecks.md │ ├── on-premise │ │ ├── README.md │ │ ├── aws.md │ │ ├── baremetal.md │ │ ├── faq.md │ │ ├── gcp.md │ │ ├── general-informations.md │ │ └── helm.md │ └── overview.md ├── plus │ ├── best-practices │ │ ├── README.md │ │ ├── cpu-profiling.md │ │ ├── memory-profiling.md │ │ ├── metrics-glossary.md │ │ └── transaction-tracing.md │ ├── faq.md │ ├── guide │ │ ├── README.md │ │ ├── app-dashboard.md │ │ ├── configuration.md │ │ ├── cpu-profiling.md │ │ ├── custom-actions.md │ │ ├── custom-metrics.md │ │ ├── installation.md │ │ ├── issue-dashboard.md │ │ ├── memory-profiling.md │ │ ├── memory-snapshot.md │ │ ├── modules.md │ │ ├── notifications.md │ │ ├── realtime-logs.md │ │ ├── server-apps-overview.md │ │ └── transaction-tracing.md │ ├── integration │ │ ├── README.md │ │ ├── cloud-providers.md │ │ ├── docker.md │ │ ├── elastic-beanstalk.md │ │ ├── heroku.md │ │ └── now.md │ ├── overview.md │ ├── quick-start.md │ └── reference │ │ └── pm2io.md └── runtime │ ├── best-practices │ ├── README.md │ ├── environment-variables.md │ ├── graceful-shutdown.md │ └── stateless-application.md │ ├── features │ ├── #memory-limit.md# │ ├── commands-cheatsheet.md │ ├── memory-limit.md │ ├── multiple-pm2.md │ ├── restart-strategies.md │ ├── source-maps.md │ ├── updating-pm2.md │ └── watch-restart.md │ ├── guide │ ├── development-tools.md │ ├── easy-deploy-with-ssh.md │ ├── ecosystem-file.md │ ├── entrypoint.md │ ├── installation.md │ ├── load-balancing.md │ ├── log-management.md │ ├── process-management.md │ └── startup-hook.md │ ├── integration │ ├── cloud-providers.md │ ├── docker.md │ ├── elastic-beanstalk.md │ ├── heroku.md │ ├── now.md │ └── transpilers.md │ ├── overview.md │ ├── quick-start.md │ └── reference │ ├── ecosystem-file.md │ ├── pm2-cli.md │ ├── pm2-programmatic.md │ └── raw_data │ ├── cli-old.md │ ├── ecosystem-file.md │ └── index.d.ts ├── gulpfile.js ├── img ├── backgrounds │ ├── bg-doc_enterprise.png │ ├── bg-doc_plus.png │ ├── bg-doc_runtime.png │ └── bg-squares.png ├── enterprise │ ├── alert_global.png │ ├── enterprise-black.png │ ├── frontend-1.png │ ├── frontend-2.png │ ├── frontend-3.png │ ├── logs.png │ └── rect-e.png ├── enterprise_docs.svg ├── keymetrics-docs.svg ├── logos-pm2 │ ├── pm2-enterprise_white.png │ ├── pm2-plus_white.png │ ├── pm2-runtime_white.png │ ├── pm2_enterprise.svg │ ├── pm2_monitoring.svg │ ├── pm2_runtime.svg │ └── pm2_white.svg ├── plus │ ├── 2views.png │ ├── apps.png │ ├── cpu-profiling.png │ ├── flame-graph.png │ ├── issue.old.png │ ├── issue.png │ ├── memory-profiling.png │ ├── modules.png │ ├── notifications.png │ ├── personalized.old.png │ ├── personalized.png │ ├── plus-black.png │ ├── profiling.old.png │ ├── remote.old.png │ ├── remote.png │ ├── server.png │ ├── tracing.old.png │ ├── tracing.png │ ├── unified.old.png │ └── unified.png ├── plus_docs.svg ├── pm2-docs.svg ├── pm2-white.svg ├── pm2_docs_og.png ├── runtime │ ├── IAM-add.png │ ├── IAM-creds.png │ ├── IAM-prog.png │ ├── IAM-strat.png │ ├── autocomplete.png │ ├── cluster-mode.png │ ├── help.png │ ├── monit.png │ ├── pm2ls.png │ ├── rect-r.png │ └── runtime-black.png ├── runtime_docs.svg └── sidebar2 │ ├── pm2_enterprise.svg │ ├── pm2_monitoring.svg │ ├── pm2_runtime.svg │ └── pm2_white.svg ├── index.md ├── js ├── lib │ ├── clipboard.min.js │ ├── gitalk.min.js │ ├── md5.min.js │ └── prism.js ├── main.js └── prism-clipboard.js ├── misc ├── cli-parser.js ├── ecosystem-parser.js └── metrics.js ├── package.json ├── static ├── hamburger-enterprise.png ├── hamburger-monitoring.png ├── hamburger-runtime.png ├── pm-2.png ├── pm-2@2x.png ├── pm-2@3x.png ├── pm2-logo-e.png ├── pm2-logo-m.png └── pm2-logo-r.png ├── yarn.lock └── zh ├── enterprise └── overview.md ├── plus ├── best-practices │ ├── README.md │ ├── cpu-profiling.md │ ├── memory-profiling.md │ ├── metrics-glossary.md │ └── transaction-tracing.md ├── guide │ ├── README.md │ ├── configuration.md │ ├── installation.md │ ├── issue-dashboard.md │ ├── memory-cpu-profiling.md │ ├── modules.md │ ├── notifications.md │ └── transaction-tracing.md ├── integration │ ├── README.md │ ├── cloud-providers.md │ ├── docker.md │ ├── elastic-beanstalk.md │ └── heroku.md ├── overview.md ├── quick-start.md └── reference │ └── pmx.md └── runtime ├── best-practices ├── README.md ├── environment-variables.md ├── graceful-shutdown.md └── stateless-application.md ├── guide ├── README.md ├── development-tools.md ├── easy-deploy-with-ssh.md ├── ecosystem-file.md ├── installation.md ├── load-balancing.md ├── log-management.md ├── process-management.md └── startup-hook.md ├── integration ├── README.md ├── cloud-providers.md ├── docker.md ├── elastic-beanstalk.md ├── heroku.md └── transpilers.md ├── overview.md ├── quick-start.md └── reference ├── README.md ├── ecosystem-file.md ├── pm2-cli.md └── pm2-programmatic.md /.drone.yml.bkp: -------------------------------------------------------------------------------- 1 | --- 2 | kind: pipeline 3 | name: default 4 | trigger: 5 | branch: 6 | - master 7 | event: 8 | - push 9 | 10 | steps: 11 | - name: publish 12 | image: plugins/docker 13 | settings: 14 | repo: keymetrics/pm2-docs 15 | tags: 16 | - latest 17 | - "${DRONE_COMMIT_SHA}" 18 | password: 19 | from_secret: docker_password 20 | username: 21 | from_secret: docker_username 22 | - name: Generate infrastructure PR 23 | image: keymetrics/drone-plugin-auto-pr 24 | pull: true 25 | environment: 26 | GITHUB_OAUTH_TOKEN: 27 | from_secret: github_token 28 | settings: 29 | owner: keymetrics 30 | repository: infrastructure 31 | regex: 'keymetrics/pm2-docs:([A-Za-z0-9]+)' 32 | files: 33 | - 'jobs/frontend.nomad' 34 | message: 'chore: update pm2 doc jobs' 35 | - name: slack 36 | image: plugins/slack 37 | settings: 38 | channel: dev-stream-ci 39 | status: 40 | - success 41 | - failure 42 | template: "{{#success build.status}}\n {{repo.name}} : {{build.event}} with commit {{truncate build.commit 8}} on branch \"{{build.branch}}\" done by {{build.author}} succeeded in {{since build.started}}\n{{else}}\n {{repo.name}} : {{build.event}} with commit {{truncate build.commit 8}} on branch \"{{build.branch}}\" done by {{build.author}} failed in {{since build.started}}\n{{/success}}\nsee {{ build.link }}\n" 43 | webhook: 44 | from_secret: slack_webhook 45 | 46 | --- 47 | kind: secret 48 | name: slack_webhook 49 | get: 50 | path: secret/drone/slack 51 | name: url 52 | 53 | --- 54 | kind: secret 55 | name: docker_username 56 | get: 57 | path: secret/drone/docker 58 | name: username 59 | 60 | --- 61 | kind: secret 62 | name: docker_password 63 | get: 64 | path: secret/drone/docker 65 | name: password 66 | 67 | --- 68 | kind: secret 69 | name: github_token 70 | get: 71 | path: secret/drone/github 72 | name: token -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | */**/.DS_Store 3 | .DS_Store 4 | uru* 5 | _site/ 6 | .sass-cache/ 7 | .jekyll-cache/ 8 | .jekyll-metadata 9 | docs 10 | package-lock.json 11 | dist 12 | Gemfile.lock 13 | -------------------------------------------------------------------------------- /.stylelintrc: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "stylelint-config-standard" 3 | } -------------------------------------------------------------------------------- /CNAME: -------------------------------------------------------------------------------- 1 | doc.pm2.io -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ruby:2.5-alpine 2 | 3 | RUN apk add --no-cache --virtual build-dependencies make gcc g++ python build-base git cmake 4 | RUN gem install pygments.rb jekyll 5 | 6 | ENV LANGUAGE en_US.UTF-8 7 | ENV LANG en_US.UTF-8 8 | ENV LC_ALL en_US.UTF-8 9 | 10 | WORKDIR /docs 11 | 12 | ADD Gemfile /docs 13 | ADD Gemfile.lock /docs 14 | 15 | RUN bundle install 16 | 17 | ADD . /docs 18 | RUN bundle exec jekyll build 19 | 20 | FROM kyma/docker-nginx 21 | 22 | RUN mkdir -p /var/www 23 | COPY --from=0 /docs/docs /var/www 24 | EXPOSE 80 25 | 26 | CMD 'nginx' 27 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | source "http://rubygems.org" 2 | 3 | # Hello! This is where you manage which Jekyll version is used to run. 4 | # When you want to use a different version, change it below, save the 5 | # file and run `bundle install`. Run Jekyll with `bundle exec`, like so: 6 | # 7 | # bundle exec jekyll serve 8 | # 9 | # This will help ensure the proper Jekyll version is running. 10 | # Happy Jekylling! 11 | gem "jekyll", "~> 3.6.2" 12 | 13 | # This is the default theme for new Jekyll sites. You may change this to anything you like. 14 | # gem "minima", "~> 2.0" 15 | 16 | # If you want to use GitHub Pages, remove the "gem "jekyll"" above and 17 | # uncomment the line below. To upgrade, run `bundle update github-pages`. 18 | # gem "github-pages", group: :jekyll_plugins 19 | 20 | # If you have any plugins, put them here! 21 | group :jekyll_plugins do 22 | gem 'jekyll-redirect-from' 23 | end 24 | 25 | gem "nokogiri", "~> 1.8.1" 26 | gem "wdm", "~> 0.1.1" if Gem.win_platform? 27 | # gem 'html-proofer' 28 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | Offical PM2 Documentation [https://doc.pm2.io/](https://doc.pm2.io/) 3 | -------------------------------------------------------------------------------- /SETUP.md: -------------------------------------------------------------------------------- 1 | # PM2 Documentation 2 | 3 | ## Install Jekyll 4 | 5 | ``` bash 6 | sudo apt install clang make ruby-dev libffi-dev 7 | bundle install 8 | ``` 9 | 10 | ## Start in dev mode 11 | 12 | ```bash 13 | $ npm install gulp -g 14 | $ npm install 15 | $ gulp 16 | ``` 17 | 18 | Then connect to `http://localhost:4010/doc/` 19 | 20 | ## Build for production 21 | 22 | ```bash 23 | $ gulp dist 24 | ``` 25 | 26 | ## Configuring Algolia Search 27 | 28 | [Algolia crawler configuration file](https://github.com/algolia/docsearch-configs/blob/master/configs/pm2docs.json) 29 | -------------------------------------------------------------------------------- /_config.yml: -------------------------------------------------------------------------------- 1 | # Site settings 2 | name: PM2 Documentation 3 | email: contact@pm2.io 4 | description: 'PM2 - Guide, References, Tutorials and Best Practices about PM2 and Node.js.' 5 | 6 | # Build settings 7 | sass: 8 | style: compressed 9 | 10 | markdown: kramdown 11 | highlighter: rouge 12 | 13 | kramdown: 14 | input: GFM 15 | auto_ids: true 16 | hard_wrap: false 17 | parse_block_html: true 18 | syntax_highlighter: rouge 19 | 20 | repository: 'keymetrics/doc-pm2' 21 | permalink: pretty 22 | plugins: 23 | - jekyll-redirect-from 24 | 25 | destination: docs 26 | 27 | exclude: 28 | - Dockerfile 29 | - Gemfile 30 | - Gemfile.lock 31 | - gulpfile.js 32 | - misc 33 | - node_modules 34 | - package.json 35 | - package-lock.json 36 | - README.md 37 | - yarn.lock 38 | -------------------------------------------------------------------------------- /_data/sidebar-zh.yml: -------------------------------------------------------------------------------- 1 | runtime: 2 | - title: 概述 3 | url: "/zh/runtime/overview/" 4 | - title: 快速开始 5 | url: "/zh/runtime/quick-start/" 6 | - title: 指南 7 | submenu: 8 | - page: 安装 9 | url: "/zh/runtime/guide/installation/" 10 | - page: 生态系统文件 11 | url: "/zh/runtime/guide/ecosystem-file/" 12 | - page: 进程管理 13 | url: "/zh/runtime/guide/process-management/" 14 | - page: 日志管理 15 | url: "/zh/runtime/guide/log-management/" 16 | - page: 启动挂钩 17 | url: "/zh/runtime/guide/startup-hook/" 18 | - page: 负载平衡 19 | url: "/zh/runtime/guide/load-balancing/" 20 | - page: 开发工具 21 | url: "/zh/runtime/guide/development-tools/" 22 | - page: 使用SSH轻松部署 23 | url: "/zh/runtime/guide/easy-deploy-with-ssh/" 24 | - title: 最佳实践 25 | submenu: 26 | - page: 中的环境变量 27 | url: "/zh/runtime/best-practices/environment-variables/" 28 | - page: 正常关机 29 | url: "/zh/runtime/best-practices/graceful-shutdown/" 30 | - page: 无状态应用 31 | url: "/zh/runtime/best-practices/stateless-application/" 32 | - title: 综合 33 | submenu: 34 | - page: AWS Elastic Beanstalk 35 | url: "/zh/runtime/integration/elastic-beanstalk/" 36 | - page: Docker 37 | url: "/zh/runtime/integration/docker/" 38 | - page: Heroku 39 | url: "/zh/runtime/integration/heroku/" 40 | - page: Transpilers 41 | url: "/zh/runtime/integration/transpilers/" 42 | - page: 使用云供应商 43 | url: "/zh/runtime/integration/cloud-providers/" 44 | - title: 参考 45 | submenu: 46 | - page: Ecosystem 文件 47 | url: "/zh/runtime/reference/ecosystem-file/" 48 | - page: CLI 49 | url: "/zh/runtime/reference/pm2-cli/" 50 | - page: 程序化 51 | url: "/zh/runtime/reference/pm2-programmatic/" 52 | 53 | plus: 54 | - title: 概述 55 | url: "/zh/plus/overview/" 56 | - title: 快速入门 57 | url: "/zh/plus/quick-start/" 58 | - title: 指南 59 | submenu: 60 | - page: 安装 61 | url: "/zh/plus/guide/installation/" 62 | - page: 配置 63 | url: "/zh/plus/guide/configuration/" 64 | - page: 通知 65 | url: "/zh/plus/guide/notifications/" 66 | - page: 问题仪表板 67 | url: "/zh/plus/guide/issue-dashboard/" 68 | - page: 事物跟踪 69 | url: "/zh/plus/guide/transaction-tracing/" 70 | - page: 内存和CPU分析 71 | url: "/zh/plus/guide/memory-cpu-profiling/" 72 | - title: 最佳实践 73 | url: "/zh/plus/best-practices/" 74 | submenu: 75 | - page: CPU分析 76 | url: "/zh/plus/best-practices/cpu-profiling/" 77 | - page: 内存分析 78 | url: "/zh/plus/best-practices/memory-profiling/" 79 | - page: 事物跟踪 80 | url: "/zh/plus/best-practices/transaction-tracing/" 81 | - title: 集成 82 | url: "/zh/plus/integration/" 83 | submenu: 84 | - page: AWS Elastic Beanstalk 85 | url: "/zh/plus/integration/elastic-beanstalk/" 86 | - page: Docker 87 | url: "/zh/plus/integration/docker/" 88 | - page: Heroku 89 | url: "/zh/plus/integration/heroku/" 90 | - page: 使用云供应商 91 | url: "/zh/plus/integration/cloud-providers/" 92 | - title: 参考 93 | url: "/zh/plus/reference/pmx" 94 | 95 | enterprise: 96 | - title: 概述 97 | url: "/en/enterprise/overview/" 98 | -------------------------------------------------------------------------------- /_includes/edit-page/edit-page-en.html: -------------------------------------------------------------------------------- 1 | 6 | -------------------------------------------------------------------------------- /_includes/edit-page/edit-page-zh.html: -------------------------------------------------------------------------------- 1 |
2 | 3 |
4 | -------------------------------------------------------------------------------- /_includes/footer/footer-en.html: -------------------------------------------------------------------------------- 1 | 14 | -------------------------------------------------------------------------------- /_includes/footer/footer-zh.html: -------------------------------------------------------------------------------- 1 | 13 | -------------------------------------------------------------------------------- /_includes/head.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | {{ page.title }} 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /_includes/header/header-en.html: -------------------------------------------------------------------------------- 1 |
2 |
3 |
4 | 5 | 6 | 7 |
8 |
9 | 10 | menu 11 | 12 |
13 | 20 | 21 | {% if page.section contains 'runtime' %} 22 | 28 | {% endif %} 29 | 30 |
31 | 32 |
33 |
34 | 35 |
36 |
37 |
38 |
39 | -------------------------------------------------------------------------------- /_includes/header/header-zh.html: -------------------------------------------------------------------------------- 1 |
2 |
3 |
4 | 5 | 6 | 7 |
8 |
9 | 10 | menu 11 | 12 |
13 | 20 |
21 | 22 |
23 |
24 | 25 |
26 |
27 |
28 |
29 | -------------------------------------------------------------------------------- /_includes/meta-footer.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 31 | 32 | 39 | 40 | -------------------------------------------------------------------------------- /_includes/sidebar.html: -------------------------------------------------------------------------------- 1 | 30 | -------------------------------------------------------------------------------- /_includes/sitemapxml.html: -------------------------------------------------------------------------------- 1 | 2 | {{ site.url }}{{ include.url }} 3 | -------------------------------------------------------------------------------- /_layouts/home.html: -------------------------------------------------------------------------------- 1 | 2 | {% if page.lang %} 3 | 4 | 5 | {% include head.html %} 6 | 7 | {% if page.lang == 'en' %} 8 | 9 | {% else %} 10 | 11 | {% endif %} 12 | {% include header/header-{{ page.lang }}.html %} 13 | 14 |
15 | 16 |
17 | PM2 Plus logo 18 |

Monitoring & Advanced App Management

19 |
20 |
21 | 22 | 23 |
24 | PM2 Enterprise logo 25 |

Industrial Monitoring System

26 |
27 |
28 | 29 | 30 |
31 | PM2 Runtime logo 32 |

Open Source Process Manager

33 |
34 |
35 | 36 | 37 |
38 | 39 | 40 | 43 | 44 | {% include meta-footer.html %} 45 | 46 | 47 | {% endif %} 48 | -------------------------------------------------------------------------------- /_sass/button.scss: -------------------------------------------------------------------------------- 1 | @mixin gradient($from, $to) { 2 | background: -moz-linear-gradient(45deg, $from, $to); 3 | background: -webkit-linear-gradient(45deg, $from, $to); 4 | background: linear-gradient(45deg, $from, $to); 5 | } 6 | 7 | p.btn-stylized { 8 | text-align: center; 9 | } 10 | 11 | .runtime-page { 12 | p.btn-stylized a { 13 | @include gradient(#3EB1F3, #72D9FA); 14 | } 15 | } 16 | 17 | .plus-page { 18 | p.btn-stylized a { 19 | @include gradient(#01CEA2, #61E8CB); 20 | } 21 | } 22 | 23 | .enterprise-page { 24 | p.btn-stylized a { 25 | @include gradient(#7F86F5, #BABEFD); 26 | } 27 | } 28 | 29 | p.btn-stylized a { 30 | display: inline-block; 31 | font-size: 18px; 32 | border-radius: 3px; 33 | color: white !important; 34 | text-decoration: none; 35 | // box-shadow: 0px 2px 10px #999; 36 | box-shadow: 0 5px 20px 0 rgba(0, 0, 0, 0.2); 37 | cursor: pointer; 38 | transition: all 0.3s ease; 39 | margin: 10px; 40 | padding: 10px 20px; 41 | background-size: 250% 100% !important; 42 | background-position: 100% 0% !important; 43 | 44 | &:hover { 45 | background-position: 0% !important; 46 | box-shadow: 0 0 12px #bbb; 47 | transition: all 0.3s ease; 48 | transform: translateY(-1px); 49 | } 50 | 51 | &:active { 52 | transform: translateY(0); 53 | background-position: 50% !important; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /_sass/code.scss: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/keymetrics/doc-pm2/8bf849c8ebf8abeb47c8093beec0299cb9c04d87/_sass/code.scss -------------------------------------------------------------------------------- /_sass/edit-page.scss: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/keymetrics/doc-pm2/8bf849c8ebf8abeb47c8093beec0299cb9c04d87/_sass/edit-page.scss -------------------------------------------------------------------------------- /_sass/faq.scss: -------------------------------------------------------------------------------- 1 | .faq { 2 | h2 { 3 | margin-top: 20px !important; 4 | font-size: 26px !important; 5 | } 6 | details { 7 | margin: 10px 0; 8 | padding: 3px; 9 | border-radius: 4px; 10 | } 11 | summary { 12 | //margin: 10px 0; 13 | &:hover { 14 | cursor:pointer; 15 | opacity: 0.8; 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /_sass/footer.scss: -------------------------------------------------------------------------------- 1 | .footer { 2 | margin-top: 100px; 3 | margin-bottom: 100px; 4 | text-align: center; 5 | 6 | ul { 7 | color: white; 8 | list-style-type: none; 9 | } 10 | 11 | li { 12 | line-height: 30px; 13 | } 14 | 15 | a { 16 | color: white; 17 | text-decoration: none; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /_sass/homepage.scss: -------------------------------------------------------------------------------- 1 | 2 | .homepage { 3 | .content-home { 4 | flex: 1; 5 | overflow: auto; 6 | display: flex; 7 | flex-direction: column; 8 | align-items: center; 9 | justify-content: center; 10 | background-image: url($baseurl + "/img/backgrounds/bg-squares.png"); 11 | background-position: bottom left; 12 | background-attachment: fixed; 13 | background-color: #131d26; 14 | background-size: cover; 15 | 16 | a { 17 | text-decoration: none; 18 | 19 | :hover { 20 | transition: opacity 0.15s ease-in-out; 21 | opacity: 0.6; 22 | } 23 | } 24 | 25 | .product-line { 26 | text-align: center; 27 | margin-bottom: 50px; 28 | padding: 15px; 29 | 30 | h2 { 31 | margin: 0; 32 | color: white; 33 | margin-top: 15px; 34 | font-size: 24px; 35 | } 36 | 37 | .logo-img { 38 | width: 500px; 39 | display: block; 40 | } 41 | } 42 | } 43 | } 44 | 45 | @media screen and (max-width: $mobile_offset) { 46 | .product-line { 47 | margin-bottom: 30px !important; 48 | } 49 | 50 | h2 { 51 | font-size: 22px !important; 52 | } 53 | 54 | .logo-img { 55 | margin: 0 auto; 56 | width: 250px !important; 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /_sass/main.scss: -------------------------------------------------------------------------------- 1 | $color_runtime: #3eb1f3; 2 | $color_plus: #01cea2; 3 | $color_enterprise: #7f86f5; 4 | $sidebar-width: 265px; 5 | $header-height: 76px; 6 | $baseurl: ""; 7 | $mobile_offset: 768px; 8 | 9 | @import "mobile"; 10 | @import "button"; 11 | @import "layout"; 12 | @import "edit-page"; 13 | @import "footer"; 14 | @import "header"; 15 | @import "markdown"; 16 | @import "sidebar"; 17 | @import "homepage"; 18 | @import "print-layout"; 19 | @import "prism"; 20 | @import "gitalk"; 21 | @import "faq"; 22 | -------------------------------------------------------------------------------- /_sass/mobile.scss: -------------------------------------------------------------------------------- 1 | 2 | @media screen and (max-width:$mobile_offset){ 3 | .github-corner,.sidebar,.sidebar-toggle{ 4 | position:fixed; 5 | height:200%; 6 | } 7 | .app-nav{ 8 | margin-top:16px 9 | } 10 | .app-nav li ul{ 11 | top:30px 12 | } 13 | main{ 14 | height:auto; 15 | overflow-x:hidden 16 | } 17 | .content{ 18 | transition:transform .25s ease 19 | } 20 | .app-nav,.github-corner{ 21 | transition:transform .25s ease-out 22 | } 23 | .github-corner:hover .octo-arm{ 24 | animation:none 25 | } 26 | .github-corner .octo-arm{ 27 | animation:a .56s ease-in-out 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /_sass/print-layout.scss: -------------------------------------------------------------------------------- 1 | @media print{ 2 | body { 3 | overflow: visible !important; 4 | display: block; 5 | font-size: 14px !important; 6 | background-color: white !important; 7 | } 8 | .footer { 9 | display: none; 10 | } 11 | pre, code { 12 | font-size: 13px !important; 13 | } 14 | #gitalk { 15 | display: none; 16 | } 17 | .content-container{ 18 | padding: 0px !important; 19 | } 20 | .content { 21 | display: block !important; 22 | .content-main { 23 | max-width: max-content !important; 24 | width: max-content !important; 25 | } 26 | } 27 | .app-nav,.github-corner,.sidebar,.sidebar-toggle, .PM2_search, .header-section{ 28 | display:none 29 | } 30 | .markdown-section { 31 | box-shadow: none !important; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /_sass/sidebar.scss: -------------------------------------------------------------------------------- 1 | 2 | .sidebar{ 3 | transition:transform .25s ease-out; 4 | color: white; 5 | background: #202a37; 6 | border-right:1px solid rgba(0,0,0,.07); 7 | overflow-y:auto; 8 | overflow-x: hidden; 9 | z-index:9; 10 | padding-bottom: 100px; 11 | 12 | .sidebar-nav{ 13 | line-height:2em; 14 | padding-bottom:40px 15 | } 16 | 17 | li.collapse .app-sub-sidebar { 18 | display:none 19 | } 20 | 21 | ul { 22 | list-style-type: none; 23 | margin:0; 24 | padding:0 25 | } 26 | 27 | li a { 28 | text-decoration: none; 29 | border-bottom:none; 30 | display:block; 31 | margin: 6px 0 6px 20px; 32 | 33 | &:hover { 34 | opacity: 0.7; 35 | } 36 | } 37 | 38 | ul li ul{ 39 | padding-left:20px 40 | } 41 | } 42 | 43 | @media screen and (max-width: $mobile_offset) { 44 | .sidebar { 45 | transform:translateX(-250px) 46 | } 47 | } 48 | 49 | .sidebar.open { 50 | transform:translateX(0px) 51 | } 52 | 53 | .sidebar-nav > ul{ 54 | padding: 14px 24px 16px 20px !important 55 | } 56 | .sidebar ul li ul { 57 | padding-left: 12px!important; 58 | } 59 | .sidebar-nav ul li{ 60 | margin: 14px 0 0 0; 61 | } 62 | .sidebar-nav > ul > li:first-child { 63 | margin-top: 0px !important; 64 | } 65 | 66 | .sidebar-nav a.active{ 67 | color:#3eb1f3!important; 68 | } 69 | 70 | .sidebar ul li a { 71 | color: #fff; 72 | font-weight: 500; 73 | text-align: left; 74 | letter-spacing: 1px; 75 | line-height: 1.6; 76 | font-size: 15px; 77 | } 78 | 79 | .sidebar ul li ul li a { 80 | font-size: 14px; 81 | } 82 | 83 | .runtime-page .sidebar ul li.active>a { 84 | color: $color_runtime; 85 | } 86 | 87 | .plus-page .sidebar ul li.active>a { 88 | color: $color_plus; 89 | } 90 | 91 | .enterprise-page .sidebar ul li.active>a { 92 | color: $color_enterprise; 93 | } 94 | 95 | .sidebar ul li.active>a { 96 | font-weight:600; 97 | border-right:0px; 98 | border-left: 2px solid; 99 | padding-left: 10px; 100 | position: relative; 101 | left: -10px; 102 | } 103 | -------------------------------------------------------------------------------- /css/main.scss: -------------------------------------------------------------------------------- 1 | --- 2 | --- 3 | 4 | @import "main"; 5 | -------------------------------------------------------------------------------- /css/normalize.css: -------------------------------------------------------------------------------- 1 | /*! normalize.css v7.0.0 | MIT License | github.com/necolas/normalize.css */button,hr,input{overflow:visible}audio,canvas,progress,video{display:inline-block}progress,sub,sup{vertical-align:baseline}[type=checkbox],[type=radio],legend{box-sizing:border-box;padding:0}html{line-height:1.15;-ms-text-size-adjust:100%;-webkit-text-size-adjust:100%}body{margin:0}article,aside,details,figcaption,figure,footer,header,main,menu,nav,section{display:block}h1{font-size:2em;margin:.67em 0}figure{margin:1em 40px}hr{box-sizing:content-box;height:0}code,kbd,pre,samp{font-family:monospace,monospace;font-size:1em}a{background-color:transparent;-webkit-text-decoration-skip:objects}abbr[title]{border-bottom:none;text-decoration:underline;text-decoration:underline dotted}b,strong{font-weight:bolder}dfn{font-style:italic}mark{background-color:#ff0;color:#000}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative}sub{bottom:-.25em}sup{top:-.5em}audio:not([controls]){display:none;height:0}img{border-style:none}svg:not(:root){overflow:hidden}button,input,optgroup,select,textarea{font-family:sans-serif;font-size:100%;line-height:1.15;margin:0}button,select{text-transform:none}[type=reset],[type=submit],button,html [type=button]{-webkit-appearance:button}[type=button]::-moz-focus-inner,[type=reset]::-moz-focus-inner,[type=submit]::-moz-focus-inner,button::-moz-focus-inner{border-style:none;padding:0}[type=button]:-moz-focusring,[type=reset]:-moz-focusring,[type=submit]:-moz-focusring,button:-moz-focusring{outline:ButtonText dotted 1px}fieldset{padding:.35em .75em .625em}legend{color:inherit;display:table;max-width:100%;white-space:normal}textarea{overflow:auto}[type=number]::-webkit-inner-spin-button,[type=number]::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}[type=search]::-webkit-search-cancel-button,[type=search]::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}[hidden],template{display:none} -------------------------------------------------------------------------------- /en/enterprise/collector/overview.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: page 3 | title: Overview | PM2 Enterprise Documentation 4 | menu: starter 5 | lang: en 6 | section: enterprise 7 | permalink: "/en/enterprise/collector/" 8 | --- 9 | 10 | ## Overview 11 | 12 | When installing PM2 Enterprise, you need to choose how you want to fetch monitoring data. We have multiples way to "collect" the data: 13 | 14 | - PM2 itself embed a agent, which is the default way used by most of our clients: [checkout there]({{ site.baseurl }}{% link en/enterprise/collector/pm2.md %}) 15 | - If you want to monitor a Node.js app without PM2 (usually used in containers), you can use our standalone Node.js agent: [checkout there]({{ site.baseurl }}{% link en/enterprise/collector/standalone.md %}) 16 | - Use Golang in production? you can use our beta agent: [checkout there]({{ site.baseurl }}{% link en/enterprise/collector/go.md %}) 17 | - You already have a Prometheus instance running? You can broadcast metrics from Prometheus to PM2 Enterprise: [checkout there]({{ site.baseurl }}{% link en/enterprise/collector/prometheus.md %}) 18 | -------------------------------------------------------------------------------- /en/enterprise/collector/prometheus.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: page 3 | title: Prometheus Integration | Guides | PM2 Enterprise Documentation 4 | menu: starter 5 | lang: en 6 | section: enterprise 7 | permalink: "/en/enterprise/collector/prometheus/" 8 | --- 9 | 10 | ## Overview 11 | 12 | When setting up the monitoring for your production environment, you might have already ran a Prometheus server and maybe a graphana dashboard. 13 | Even if it's possible to re-add everything on PM2 Enterprise, it would take a lot of time, that's why we developed a gateway between any prometheus and our backend. 14 | 15 | It allows you to simply drop in your configuration a remote backend, and it will start saving your metrics in PM2 Enterprise. 16 | 17 | Note that currently only the alerting system works with it, you will be able to trigger alert in PM2 Enterprise from the values of your Prometheus metrics. However we plan to support them in the Dashboards in the near future. 18 | 19 | ## Requirements 20 | 21 | The Prometheus team built a feature called `adapter` that lets you push metrics from prometheus thought HTTP. We currently only support the version `0.1.0` of this feature is supported, if you need a specific version, ask to our sales team directly. 22 | We also currently support the `snappy` compression and the `protobuf` serialization, again ask us if you need something special. 23 | 24 | ## Configuration 25 | 26 | If all the versions are good, you simply need to add this snipet to your prometheus configuration: 27 | ```yaml 28 | remote_write: 29 | - url: https://secret_endpoint/receive 30 | basic_auth: 31 | username: publicKey 32 | password: privateKey 33 | ``` 34 | 35 | Where both `publicKey` and `privateKey` are the one you can find on the dashboard. 36 | As you can see we didn't yet document the actual endpoint to push data, it's because in a private beta so if you want to try it out, just contact our sales team ! 37 | 38 | ## Best practices 39 | 40 | Please check that you are correctly pushing with the `HTTPS` protocol, since by default the adapter push in HTTP with is not secure at all. 41 | A part from that no specific action is required from you to ensure best practices. 42 | 43 | ## Questions / Answers 44 | 45 | * Why do we need to still host a prometheus instance ourselves? 46 | 47 | Because prometheus is what is called `pull based` monitoring, that means it the server that request the metrics to the client. We however are `push based` which means that you receive data from our agents that collect the metrics for us. So basically it's by design really hard to do that in our case (it would be easier if we were `pull based`). Also from a security point, you would need to expose your metrics page to the internet so our servers can reach them which is a nightmare in a security point of view. 48 | 49 | ## Common Issues 50 | 51 | * I doesn't work, i can't see any data on the dashboard ! 52 | 53 | Check the prometheus server logs for any errors, check the authentication details. Also please note that our system need few minutes for data to show up in the metrics list when you start pushing a new one. 54 | -------------------------------------------------------------------------------- /en/enterprise/frontend-monitoring/install.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: page 3 | title: Installation | Frontend Monitoring | PM2 Enterprise Documentation 4 | menu: starter 5 | lang: en 6 | section: enterprise 7 | permalink: "/en/enterprise/frontend-monitoring/install/" 8 | --- 9 | 10 | # Frontend Monitoring installation 11 | 12 | First, connect to your PM2 Enterprise dashboard. Go to your bucket, and click on **Frontend** at the top of the page. 13 | 14 | ![Frontend monitoring menu]({{ site.baseurl }}{% link img/enterprise/frontend-1.png %}) 15 | 16 | Fill in the small form, by giving your application a name (you will be able to create multiple applications within your dashboard), and listing the domains your application will be accessible from. Make sure to put your main domain first. Enable Webchecks if you want deeper metrics gathered from your main domain. 17 | 18 | ![Frontend monitoring wizard - form]({{ site.baseurl }}{% link img/enterprise/frontend-2.png %}) 19 | 20 | After submiting the form, the app will generate an HTML snippet. Just copy and paste it in your Website, just before the `` tag. 21 | 22 | ![Frontend monitoring wizard - snippet]({{ site.baseurl }}{% link img/enterprise/frontend-3.png %}) 23 | 24 | That's it! your Website is starting to be monitored by PM2, and you will see data incoming in realtime. 25 | 26 | -------------------------------------------------------------------------------- /en/enterprise/frontend-monitoring/overview.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: page 3 | title: Overview | Frontend Monitoring | PM2 Enterprise Documentation 4 | menu: starter 5 | lang: en 6 | section: enterprise 7 | hide_comments: true 8 | permalink: "/en/enterprise/frontend-monitoring/overview/" 9 | --- 10 | 11 | # Frontend Monitoring overview 12 | 13 | Start monitoring your website frontend inside your PM2 dashboard. This will allow collecting and inspecting: 14 | 15 | * uncaught JavaScript exceptions experienced by your users 16 | * users unexpected behaviors (rage clicks, rage reloads...) 17 | * bad user experiences (slow requests...) 18 | -------------------------------------------------------------------------------- /en/enterprise/guides/dashboard.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: page 3 | title: Dashboards | Guides | PM2 Enterprise Documentation 4 | menu: starter 5 | lang: en 6 | section: enterprise 7 | hide_comments: true 8 | permalink: "/en/enterprise/guides/dashboard/" 9 | --- 10 | 11 | # Overview 12 | 13 | It's common in the devops culture to have a screen in your office that monitor the state your production apps. 14 | This feature is actually that. It allows you to see what's going on in realtime so you detect faster any wrong behavior of your application. 15 | We've recently added the possibility to add widget with historic data for any metrics. 16 | 17 | ## Use cases 18 | 19 | #### Have an overview of what's happening 20 | 21 | The main use case of this feature is of course to have an overview of all the important metrics of your app in one place, to avoid looking at multiple dashboards to have all the informations. 22 | 23 | #### Detect error quickly 24 | 25 | The dashboards can also help you detect faster issue if you have a screen constantly showing your dashboard, any developer can look at it and might see a wrong behavior at any time, even before the alerts comes if you have configured some. 26 | 27 | ## Requirements 28 | 29 | In the following documention, we assume that you already have connected your application to PM2 Enterprise (either on-premise and cloud). 30 | We also assume that you know how custom metrics works. 31 | 32 | ## Configuration 33 | 34 | Since the feature is really just customization for your needs, there a no specific configuration to have. You need to evaluate what you want to see on your dashboard and configure each compoments to show you what you want. 35 | 36 | ## Common Questions 37 | 38 | * Is there a way to show historic value of a metric? 39 | 40 | Yes, you need to use the "Metric line chart" widget which allows you to specify a timerange. Other widget are only in realtime. 41 | 42 | * I need to show a metric in a specific way (one that isn't covered by one of your component)? 43 | 44 | We are totally open to implement other components, please contact us so we can discuss that ! 45 | 46 | ## Common Issues 47 | 48 | * It's slow on my PC 49 | 50 | The realtime dashboard can cost a lot depending on how much process you want to monitor in realtime, we are constantly looking to optimize our frontend, we advise to contact us so we can inspect the problem and find a solution. 51 | -------------------------------------------------------------------------------- /en/enterprise/on-premise/README.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: page 3 | title: On-Premise | PM2 Enterprise Documentation 4 | menu: starter 5 | lang: en 6 | section: enterprise 7 | hide_comments: true 8 | permalink: "/en/enterprise/on-premise/" 9 | redirect_to: 10 | - https://www.github.com/keymetrics/on-premise 11 | --- 12 | -------------------------------------------------------------------------------- /en/enterprise/on-premise/baremetal.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: page 3 | title: Deployment on Baremetal Servers | On-Premise | PM2 Enterprise Documentation 4 | menu: starter 5 | lang: en 6 | section: enterprise 7 | permalink: "/en/enterprise/on-premise/baremetal/" 8 | --- 9 | 10 | # Deployment on Baremetal Servers 11 | 12 | Note that this tutorial is only made if you decided to deploy PM2 Enterprise On-Premise. If you use the Cloud based one you can just use it straight from https://app.pm2.io 13 | 14 | ## Requirements 15 | 16 | Install Docker & Docker compose (minimum required version is 1.19.0) in your host machine: 17 | 18 | ```bash 19 | $ sudo wget -qO- https://get.docker.com/ | sh 20 | $ sudo curl -L https://github.com/docker/compose/releases/download/1.19.0/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose 21 | $ sudo chmod +x /usr/local/bin/docker-compose 22 | ``` 23 | 24 | Then make sure you have logged-in on the hub to be able to pull the private images: 25 | 26 | ```bash 27 | $ docker login 28 | ``` 29 | 30 | ## Steps to Install 31 | 32 | 1. Get the docker-compose.yml file corresponding to your version: 33 | 34 | ```bash 35 | $ wget https://raw.githubusercontent.com/keymetrics/on-premise/master/docker/docker-compose.yml 36 | ``` 37 | 38 | Once you have configured the `docker-compose.yml` file start it: 39 | 40 | ```bash 41 | $ docker-compose up -d 42 | ``` 43 | 44 | Now connect to: 45 | 46 | ```bash 47 | $ google-chrome http://server-ip/wizard 48 | ``` 49 | 50 | Set your License Key and configuration and youre done 51 | 52 | ## Update Procedure 53 | 54 | Just run docker-compose up again and it will pull the latest backend image: 55 | 56 | ```bash 57 | $ docker-compose pull km-api km-front 58 | $ docker-compose restart km-api km-front 59 | ``` 60 | 61 | A downtime of around 30 seconds maximum will happen. 62 | 63 | ## FAQ 64 | 65 | - *Backend cannot connect to Elasticsearch*: make sure you have a clean docker installation and there are no conflicting networks (docker networks) 66 | 67 | - *Everything is started as expected but I cannot access the interface / I cannot link PM2*: Make sure you have set the right `KM_SITE_URL` because without a proper value PM2 agent will not be able to connect to the Backend 68 | 69 | - *Do I loose the ES/Mongo data on restart?* No, by default, there are local volumes bound to the 70 | 71 | - *I want to use specific version of mongodb/redis/elasticsearch, is this possible?* No, we currently support mongodb up to 3.4, redis 2/3/4 and elasticsearch 5.5. 72 | -------------------------------------------------------------------------------- /en/enterprise/on-premise/faq.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: page 3 | title: FAQ | On-Premise | PM2 Enterprise Documentation 4 | menu: starter 5 | lang: en 6 | section: enterprise 7 | permalink: "/en/enterprise/on-premise/faq/" 8 | --- 9 | 10 | # FAQ 11 | 12 | ## The register hang or don't redirect me to the application 13 | 14 | You need to verify that the `KM_SITE_URL` you configured is the endpoint you use to connect to the frontend. If you modify it, you need to delete the mongodb database afterwards because all the endpoints configurations are stored inside it. 15 | 16 | ## What are the services that are used? 17 | 18 | - http API on port 3010 (access the data, configure bucket etc) 19 | - auth service on port 3100 (register/login etc) 20 | - websocket service on port 4010 (so the frontend can receive update in realtime) 21 | - interaction on port 3900 (listen for PM2 data) 22 | - reverse interaction on port 43554 (listen for a specific connection from PM2, used to send command to it like restart etc) 23 | 24 | ## What is exposed by default? 25 | 26 | Depending on how you deployed the keymetrics enterprise product, there are different answers: 27 | 28 | - **Docker** 29 | - nginx is used to load balance depending on the path, to either the frontend or backend services 30 | - km-front expose the frontend on the port 80 31 | - km-api expose all the backend services 32 | - **AWS** 33 | - Everything is running inside the km-core AMI 34 | - **GCP** 35 | - Same as AWS, everything is running inside the km-core API 36 | 37 | 38 | ## I get a error about `Unknown modifier: $pushAll`, what did i miss? 39 | 40 | We only support mongodb up to version 3.4 for now, you need to downgrade. 41 | 42 | ## How do i configure my pm2 to connect to it? 43 | 44 | When you first register, you should have a bucket created automatically, then you will have connection data in the middle in this format: 45 | 46 | ```bash 47 | > KEYMETRICS_NODE= pm2 link 48 | ``` 49 | 50 | You have two way to link your pm2: 51 | 52 | - Connect to the instance where pm2 is and run the command. 53 | - If you have container, just add these environements variables: 54 | - `KEYMETRICS_PUBLIC`: replace with `identifier_two>` 55 | - `KEYMETRICS_SECRET`: replace with `` 56 | - `KEYMETRICS_NODE`: replace with `` 57 | - `INSTANCE_NAME`: (optional) replace it if you want your server in keymetrics to have a fixed name 58 | 59 | Then it should all the instances in the keymetrics frontend in realtime. 60 | 61 | ## How should i run pm2 inside my containers to connect to it? 62 | 63 | We advise you to use `pm2-runtime`, it should be a dropin replacement for node inside your images: 64 | 65 | ```docker 66 | FROM node:8-alpine 67 | 68 | RUN npm install -g pm2 2> /dev/null 69 | [ ... ] 70 | CMD [ "pm2-runtime", "app.js" ] # note that you can use an ecosystem here too 71 | ``` 72 | 73 | You can find the flags that you can use [here](https://github.com/Unitech/pm2/blob/master/lib/binaries/Runtime4Docker.js#L17) 74 | -------------------------------------------------------------------------------- /en/enterprise/on-premise/helm.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: page 3 | title: Deployment on Kubernetes with Helm | On-Premise | PM2 Enterprise Documentation 4 | menu: starter 5 | lang: en 6 | section: enterprise 7 | permalink: "/en/enterprise/helm/" 8 | --- 9 | 10 | ## Deployment on Kubernetes with Helm 11 | 12 | Documentation about how to deploy the keymetrics on-premise version on Kubernetes using Helm 13 | 14 | ### Requirements 15 | 16 | In the following examples, we assume that you already have a fully working Kubernetes cluster with a working installation of Helm. 17 | To install and learn how to use Helm, you can follow the [Helm Quick Start Guide](https://docs.helm.sh/using_helm/#quickstart). 18 | 19 | ### Setup steps 20 | 21 | #### 1. Clone this repository 22 | 23 | The first step is to locally clone this git repository: 24 | 25 | `git clone https://github.com/keymetrics/on-premise.git km-on-premise` 26 | 27 | `cd km-on-premise/helm/` 28 | 29 | #### 2. Add the "incubator" repository needed for ElasticSearch chart 30 | 31 | Because the ElasticSearch chart isn't a stable chart yet, we need to add its repository to the list of allowed ones. 32 | 33 | `helm repo index incubator --url http://storage.googleapis.com/kubernetes-charts-incubator` 34 | 35 | #### 3. Install the chart 36 | 37 | The automatic installation is done using: 38 | 39 | ``` 40 | helm install keymetrics-aio --set km_license= \ 41 | --set km_public_dns= \ 42 | --set km_smtp_host= \ 43 | --set km_smtp_user= \ 44 | --set km_smtp_pass= \ 45 | --set km_smtp_sender= 46 | ``` 47 | 48 | This will install PM2 Plus and its requirements: 49 | - [Redis](https://github.com/kubernetes/charts/tree/master/stable/redis 50 | ) 51 | - [ElasticSearch](https://github.com/kubernetes/charts/tree/master/incubator/elasticsearch) 52 | - [MongoDB](https://github.com/kubernetes/charts/tree/master/stable/mongodb) 53 | 54 | These settings are required: 55 | 56 | - `km_license`: You PM2 Plus license key. 57 | - `km_public_dns`: The public dns record that will be pointing to your PM2 Plus instance (needed for requirections). 58 | - `km_smtp_host`: SMTP Server address. 59 | - `km_smtp_user`: SMTP Server username. 60 | - `km_smtp_pass`: SMTP Server password. 61 | - `km_smtp_sender`: Emails used in "From" field of emails. 62 | 63 | Once the installation is done, Helm is going to print a summary of the resources that it created. Make sure to follow the `NOTES` in order to set you DNS correctly and the connect to the web interface. -------------------------------------------------------------------------------- /en/enterprise/overview.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: page 3 | title: Overview | PM2 Enterprise Documentation 4 | menu: starter 5 | lang: en 6 | section: enterprise 7 | hide_comments: true 8 | permalink: "/en/enterprise/overview//" 9 | --- 10 | 11 |

12 | 13 |

14 |

15 | P(rocess) M(anager) 2
16 | Enterprise 17 |

18 | 19 | **PM2 Enterprise** is an advanced Node.js toolset that is convenient for high scale or critical Node.js services. 20 | It answers to the need of companies willing to bet a lot on Node.js and be confident on their technology switch. 21 | 22 | Here a quick description of each of the Enterprise feature currently available in the PM2 Enterprise product: 23 | 24 | - Dashboards: 25 | If you have a lot of metrics that you want to track, you might have the problem to display a lot of them the way you want. Each dashboard is customizable, each component on it is configurable (apps/servers/metrics etc) and moveable anywhere on the dashboard. 26 | 27 | - Alerting: 28 | This feature is the opposite of the Anomalies, sometimes you want to create manual alert for specific metrics, with this feature you are able to configure the threshold and the actions that result, you can ask to receive an email, a slack message or trigger pm2 action (like a pm2 restart) directly on application. We also added the possibility to trigger directly profiling into the application if you want to collect cpu or memory profiling on your production environment, it will launch and save it for you to inspect it later. 29 | 30 | - Logs: 31 | Currently PM2 Plus only offer the realtime logs where you can only know what's happening in realtime, with Enterprise we also store the logs of the application so you can checkout them later if you want to, no need to ssh into your servers anymore to see the logs. 32 | 33 | - Memory Profiling: 34 | In PM2 Plus you have the CPU profiling which help you know which function is using the most cpu usage, with Enterprise you have the same system but for the memory, you are able to exactly know which function is allocating memory in your application. It can help you pinpoint exactly which function is responsible for memory leak. 35 | Note that the profiling can be launched in production because it's running in parallel of your application, no need to try to reproduce any cpu/memory issue in development anymore, just launch directly the profiling where the issue is happening. 36 | 37 | - Profiling: 38 | In the Enterprise product, we also added the possibility to store all the profiling that you run on your applications so you can compare them, review them and see how a change in your code is impacting the cpu/memory consumption. 39 | 40 | ## On-premise Installation 41 | 42 | We offer different way of delivering PM2 Enterprise via easily installable on-premise system or dedicated/managed instances. 43 | 44 | [Checkout the on-premise documentation](https://github.com/keymetrics/on-premise) 45 | {: .btn-stylized} 46 | -------------------------------------------------------------------------------- /en/plus/best-practices/README.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: page 3 | title: Best Practices | PM2 Plus Documentation 4 | menu: starter 5 | lang: en 6 | section: plus 7 | hide_comments: true 8 | permalink: /en/plus/best-practices/ 9 | --- 10 | 11 | # Monitoring Best Practices 12 | 13 | This section gathers best practices to make your app scalable from the beginning. 14 | 15 | - [Metrics Glossary]({{ site.baseurl }}{% link en/plus/best-practices/metrics-glossary.md %}) 16 | - [CPU Profiling]({{ site.baseurl }}{% link en/plus/best-practices/cpu-profiling.md %}) 17 | -------------------------------------------------------------------------------- /en/plus/best-practices/memory-profiling.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: page 3 | title: Memory Profiling | Best Practices | PM2 Plus Documentation 4 | menu: starter 5 | lang: en 6 | section: plus 7 | permalink: /en/plus/best-practices/memory-profiling/ 8 | --- 9 | 10 | # Memory Profiling 11 | 12 | Article available soon. 13 | 14 | 28 | -------------------------------------------------------------------------------- /en/plus/best-practices/metrics-glossary.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: page 3 | title: Metrics Glossary | Best Practices | PM2 Plus Documentation 4 | menu: starter 5 | lang: en 6 | section: plus 7 | permalink: "/en/plus/best-practices/metrics-glossary/" 8 | --- 9 | 10 | # Metrics Glossary 11 | 12 | This glossary is an exhaustive list of all metrics recorded by PM2 Plus. Understand what a metric stands for and how it is computed will avoid you to draw conclusions too quickly. 13 | 14 | Note that each metric always describes the state of a specific application on a specific server. You may find some cross server metrics on the dashboard, to suggest on which application you could use the profiling for example, but in most cases, metrics are application and server specific. 15 | 16 | ## CPU Usage 17 | 18 | The CPU usage is the amount of time the CPU is busy. A CPU only can handle one operation at a time and so is either busy or idle. 19 | 20 | Unit: % 21 | Range of values: 0 - 100 22 | 23 | ## Memory Usage 24 | 25 | The memory usage is the total amount of memory used by the application. 26 | 27 | Unit: Megabytes (MB) 28 | Range of values: 0 - total memory of the server 29 | 30 | ## Issues 31 | 32 | The number of new issues recorded in the app. 33 | 34 | ## Number of restart 35 | 36 | The number of restart of your application since added to the PM2 process list. PM2 automatically restarts your application whenever needed, for example after an uncaught exception has happened. 37 | 38 | ## Number of processes 39 | 40 | The number of cluster on which your app has been spread on the server. Only PM2 clusters appear. 41 | 42 | ## HTTP Requests per Minutes 43 | 44 | Unit: Number of requests / minutes 45 | 46 | ## Loop Delay 47 | 48 | Unit: milliseconds (ms) 49 | Range: 0 - less than 100ms 50 | 51 | The time the Node.js event loop takes to complete a loop. 52 | 53 | ## Active Handles 54 | 55 | Handles represent long-lived objects capable of performing certain operations while active. Some examples: 56 | 57 | - A prepare handle gets its callback called once every loop iteration when active. 58 | - A TCP server handle that gets its connection callback called every time there is a new connection. 59 | 60 | ## Active Requests 61 | 62 | Requests represent short-lived operations. These operations can be performed over a handle: write requests are used to write data on a handle; or standalone: getaddrinfo requests don’t need a handle they run directly on the loop. 63 | 64 | ## Node.js Memory 65 | 66 | ## New space used size 67 | 68 | ## Old space used size 69 | 70 | ## Map space used size 71 | 72 | ## Code space used size 73 | 74 | ## Large object space used suze 75 | 76 | ## Heap size 77 | 78 | ## Heap size executable 79 | 80 | ## Used heap size 81 | 82 | ## Heap size limit 83 | 84 | ## Garbage Collector 85 | 86 | ## GC heap size 87 | 88 | ## GC executable heap size 89 | 90 | ## GC used heap size 91 | 92 | ## GC type 93 | 94 | ## Gc Pause 95 | -------------------------------------------------------------------------------- /en/plus/best-practices/transaction-tracing.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: page 3 | title: Transaction Tracing | Best Practices | PM2 Plus Documentation 4 | menu: starter 5 | lang: en 6 | section: plus 7 | permalink: "/en/plus/best-practices/transaction-tracing/" 8 | --- 9 | 10 | # Transaction Tracing 11 | 12 | Article available soon. 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /en/plus/guide/README.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: page 3 | title: Guide | PM2 Plus Documentation 4 | menu: starter 5 | lang: en 6 | section: plus 7 | hide_comments: true 8 | permalink: "/en/plus/guide/" 9 | --- 10 | 11 | # Guide 12 | 13 | Follow this guide and get your Node.js app monitored by PM2 Plus in minutes! 14 | 15 | ## Terminology 16 | 17 | Let's first explain some terminology we will use across this guide: 18 | 19 | A **bucket** is an entity related to PM2 Plus which is associated to a billing plan. Buckets are generally used to group and monitor multiple servers of a single project. 20 | 21 | A **server** is a container or a machine with a PM2 daemon managing one or more processes. 22 | 23 | A **process** is an entity of the process list (`pm2 ls`). This is one instance of an app which has been started by PM2. 24 | 25 | [Let's start]({{ site.baseurl }}{% link en/plus/guide/installation.md %}) 26 | {: .btn-stylized} 27 | -------------------------------------------------------------------------------- /en/plus/guide/app-dashboard.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: page 3 | title: App Dashboard | Guide | PM2 Plus Documentation 4 | menu: starter 5 | lang: en 6 | section: plus 7 | permalink: "/en/plus/guide/app-dashboard/" 8 | --- 9 | 10 | # Application Dashboard 11 | 12 | ![Dashboard](https://raw.githubusercontent.com/keymetrics/branding/master/screenshots/plus/dashboard/dashboard.png) 13 | 14 | This dashboard is used to give you insight on a particular application. 15 | 16 | At the top you will see a map again, each of the rectangle represent one hour and its color depend on what was happening during this hour. 17 | Each color have a different meaning: 18 | - Light blue means either a low cpu or memory usage (lower than normal) 19 | - Dark blue means either a high cpu or memory usage (higher than normal) 20 | - Blue means everything is normal 21 | - Red means we received error about the application during this hour. 22 | 23 | Then you have few metrics about this applications, for each metric you will have the historial value in the background and the realtime value in the foreground. You can customize those ones by clicking on `Configure metrics` at the far right of the screen. 24 | 25 | Finally at the bottom, we will list each servers where your application is. And for each server, we will show you the metrics about the application on this specific server. 26 | It's pretty much the same view as the `Servers overview` expect there it's only about one application. 27 | 28 | ## Next Steps 29 | 30 | [Notifications]({{ site.baseurl }}{% link en/plus/guide/notifications.md %}) 31 | {: .btn-stylized} 32 | -------------------------------------------------------------------------------- /en/plus/guide/configuration.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: page 3 | title: Configuration | Guide | PM2 Plus Documentation 4 | menu: starter 5 | lang: en 6 | section: plus 7 | permalink: "/en/plus/guide/configuration/" 8 | --- 9 | 10 | ![pm2io](https://raw.githubusercontent.com/keymetrics/branding/master/logos/pm2ioAPM/io-white.png) 11 | 12 | # Configuration 13 | 14 | Your dashboard already comes with a lot of metrics without any configuration. But don't worry, you also can add predefined set of metrics or - even better - to create custom ones. 15 | 16 | PM2 comes with the [@pm2/io](https://github.com/keymetrics/pm2-io-apm) module, which is a module that gathers the metrics displayed in `pm2 monit` or in the web dashboard. By default, it just wraps your app. If you however want to refine the configuration, add custom metrics or custom actions, you must require it in your code. 17 | 18 | ## Installation 19 | 20 | With npm: 21 | 22 | ```bash 23 | npm install @pm2/io --save 24 | ``` 25 | 26 | With yarn: 27 | 28 | ```bash 29 | yarn add @pm2/io 30 | ``` 31 | 32 | ## Intialisation 33 | 34 | Load and initialize `@pm2/io` at the top level of your application, before any other `require`. 35 | 36 | ```javascript 37 | const io = require('@pm2/io') 38 | 39 | io.init({ 40 | metrics: { 41 | network: { 42 | ports: true 43 | } 44 | } 45 | }) 46 | ``` 47 | 48 | This first basic initialisation will add to the dashboard the port number your app is listening to. 49 | 50 | See all intialisation options in the [@pm2/io reference]({{ site.baseurl }}{% link en/plus/reference/pm2io.md %}). 51 | {: .tip} 52 | 53 | ## Next Steps 54 | 55 | 56 | [@pm2/io reference]({{ site.baseurl }}{% link en/plus/reference/pm2io.md %}) 57 | {: .btn-stylized} 58 | 59 | [Custom Metrics]({{ site.baseurl }}{% link en/plus/guide/custom-metrics.md %}) 60 | {: .btn-stylized} 61 | -------------------------------------------------------------------------------- /en/plus/guide/cpu-profiling.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: page 3 | title: CPU Profiling | Guide | PM2 Plus Documentation 4 | menu: starter 5 | lang: en 6 | section: plus 7 | permalink: "/en/plus/guide/cpu-profiling/" 8 | --- 9 | 10 | # Overview 11 | 12 | ![cpu profiling]({{ site.baseurl }}{% link img/plus/cpu-profiling.png %}) 13 | 14 | The CPU profiling tool helps you better understand how CPU is used with your application. 15 | 16 | PM2 Plus makes remote CPU profiling of your production servers possible through the interface. 17 | 18 | ## How to use 19 | 20 | In order to use the CPU profiling, you must first [install the profiling tool]({{ site.baseurl }}{% link en/plus/guide/installation.md %}#install-cpumemory-profiling). 21 | 22 | For CPU profiling, you decide how long you want to record. 23 | 24 | It gets you a visualisation of the stack and still offer the ability to download the CPU profiling file. 25 | 26 | ## Next Steps 27 | 28 | [Modules]({{ site.baseurl }}{% link en/plus/guide/modules.md %}) 29 | {: .btn-stylized} 30 | -------------------------------------------------------------------------------- /en/plus/guide/installation.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: page 3 | title: Installation | Guide | PM2 Plus Documentation 4 | menu: starter 5 | lang: en 6 | section: plus 7 | permalink: "/en/plus/guide/installation/" 8 | --- 9 | 10 | # Installation 11 | 12 | We assume that your app have been started with PM2. If not, follow the [Quick Start]({{ site.baseurl }}{% link en/runtime/quick-start.md %}) tutorial. 13 | 14 | ## Create an account 15 | 16 | You can create a PM2 plus accoutn by registering [here](https://id.keymetrics.io/api/oauth/register) or juste by typing ```pm2 plus``` in your terminal. 17 | 18 | Then just simply follow the in-app tutorial 19 | ![Wizard](https://raw.githubusercontent.com/keymetrics/branding/master/screenshots/plus/wizard/step1.png) 20 | 21 | ## Connect your server to the dashboard 22 | 23 | Connect your server to your dashboard and start collecting metrics with: 24 | 25 | ```bash 26 | pm2 link 27 | ``` 28 | 29 | Or, if you don't have access to the CLI, add `PM2_PUBLIC_KEY` and `PM2_SECRET_KEY` environment variables set with your public and private keys. 30 | 31 | Use the `conncet` button on the top right of your dashboard to find your `PM2_PUBLIC_KEY` and `PM2_SECRET_KEY` 32 | {: .tip} 33 | 34 | ### If you are behind a company proxy/firewall 35 | 36 | Starting from PM2 3.2, we changed the networking connection by using a direct Websocket connection to our server on the port 443, so you only need OUTBOUND on port 443 TCP open. If you are using an older version, we of course advise to update but the ports that you need to open are 80 (TCP outbound), 443 (HTTPS outbound) and 43554 (TCP outbound), so verify everything is allowed on your firewall. 37 | 38 | You also may need to whitelist IPs, please allow these ones: 62.210.102.213, 163.172.76.240, 62.4.21.98, 163.172.253.187, 163.172.67.152, 195.154.79.25, 195.154.79.34 39 | 40 | ## Next Steps 41 | 42 | [Server Apps Overview]({{ site.baseurl }}{% link en/plus/guide/server-apps-overview.md %}) 43 | {: .btn-stylized} 44 | -------------------------------------------------------------------------------- /en/plus/guide/issue-dashboard.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: page 3 | title: Issue Dashboard | Guide | PM2 Plus Documentation 4 | menu: starter 5 | lang: en 6 | section: plus 7 | permalink: "/en/plus/guide/issue-dashboard/" 8 | --- 9 | 10 | # Issue dashboard 11 | 12 | ![issue dashboard](https://raw.githubusercontent.com/keymetrics/branding/master/screenshots/plus/issues/issues.png) 13 | 14 | By default when one of your applications crash, pm2 will of course automatically restart it but it will also send the error to PM2 Plus. 15 | In the issue dashboard, you will be able to see for each error: 16 | - How much time the error happened? 17 | - The servers that were impacted by this errors 18 | - The stack trace 19 | - The exact line of code that thrown the error 20 | - Few applications logs before the error happened 21 | 22 | You can of course delete them if you think they are not relevant by click on ` 23 | 24 | ## Manually emit an issue 25 | 26 | It's possible that you need to report an error that isn't crashing your process. 27 | In this case you can use `io.notifyError`: 28 | 29 | ```javascript 30 | const io = require('@pm2/io') 31 | 32 | try { 33 | // Critical action to be tested 34 | user.sendNotifications() 35 | } catch (error) { 36 | io.notifyError(new Error('Notification failed'), { 37 | // or anything that you can like an user id 38 | custom: { 39 | user: user.id 40 | } 41 | }) 42 | } 43 | ``` 44 | 45 | ## Next Steps 46 | 47 | [Notifications]({{ site.baseurl }}{% link en/plus/guide/custom-metrics.md %}) 48 | {: .btn-stylized} 49 | -------------------------------------------------------------------------------- /en/plus/guide/memory-profiling.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: page 3 | title: Memory Profiling | Guide | PM2 Plus Documentation 4 | menu: starter 5 | lang: en 6 | section: plus 7 | permalink: "/en/plus/guide/memory-profiling/" 8 | --- 9 | 10 | # Memory profiling 11 | 12 | ![memory profiling]({{ site.baseurl }}{% link img/plus/memory-profiling.png %}) 13 | 14 | Profiling tools help you diagnose memory issues in your application. 15 | 16 | PM2 Plus allows you to take remote heap memory snapshots of your production servers and provide you visualization tools. 17 | 18 | ## Memory profiling 19 | 20 | In order to use the memory profiling, you must first [install the profiling tool]({{ site.baseurl }}{% link en/plus/guide/installation.md %}#install-cpumemory-profiling). 21 | 22 | Click to take a heapdump and download the file. It may take some time depending on the weight of the heap file. 23 | 24 | Inspect with the Google Chrome developer tool into the Profiles tab (**Load** button). 25 | 26 | ### Tracking memory leaks 27 | 28 | To track memory leak you will need to compare multiple heapdump files to see which element is increasing over time. 29 | 30 | To know more about memory analysis check the [google tutorial](https://developer.chrome.com/devtools/docs/heap-profiling). 31 | 32 | ## Next Steps 33 | 34 | [CPU Profiling]({{ site.baseurl }}{% link en/plus/guide/cpu-profiling.md %}) 35 | {: .btn-stylized} 36 | -------------------------------------------------------------------------------- /en/plus/guide/memory-snapshot.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: page 3 | title: Memory Snapshot | Guide | PM2 Plus Documentation 4 | menu: starter 5 | lang: en 6 | section: plus 7 | permalink: "/en/plus/guide/memory-snapshot/" 8 | --- 9 | 10 | # Overview 11 | 12 | ![memory snapshot]({{ site.baseurl }}{% link img/plus/memory-profiling.png %}) 13 | 14 | This feature help you diagnose memory issues in your application. 15 | 16 | PM2 Plus allows you to take remote heap memory snapshots of your applications and provide you visualization tools. 17 | 18 | **WARNING**: There are few bugs in V8 (the engine that runs the javascript in Node.js) that can impact your applications when you are doing a memory snapshot. Specially if you use it in applications with large memory (>800MB of RAM). You should avoid running it in those cases. 19 | 20 | ## How to use 21 | 22 | In order to use the memory snapshot, you must first [install the snapshot tool]({{ site.baseurl }}{% link en/plus/guide/installation.md %}#install-cpumemory-profiling). 23 | 24 | Click to take a heapdump and download the file. It may take some time depending on the weight of the heap file. 25 | 26 | Inspect with the Google Chrome developer tool into the Profiles tab (**Load** button). 27 | 28 | ### Tracking memory leaks 29 | 30 | To track memory leak you will need to compare multiple heapdump files to see which element is increasing over time. 31 | 32 | To know more about memory analysis check the [chrome devtools tutorial](https://developer.chrome.com/devtools/docs/heap-profiling). 33 | 34 | ## Next Steps 35 | 36 | [CPU Profiling]({{ site.baseurl }}{% link en/plus/guide/cpu-profiling.md %}) 37 | {: .btn-stylized} 38 | -------------------------------------------------------------------------------- /en/plus/guide/realtime-logs.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: page 3 | title: Realtime logs | Guide | PM2 Plus Documentation 4 | menu: starter 5 | lang: en 6 | section: plus 7 | permalink: "/en/plus/guide/realtime-logs/" 8 | --- 9 | 10 | # Realtime Logs 11 | 12 | ![Logs](https://raw.githubusercontent.com/keymetrics/branding/master/screenshots/plus/logs/logs.png) 13 | 14 | In PM2 Plus you are able to stream the logs that your application output directly to the dashboard. 15 | It can be really helpful if you don't want to SSH into your servers and use `pm2 logs` 16 | 17 | Note that if you are looking for a log storage solution, you can checkout the PM2 Enterprise product which contains log retention. 18 | 19 | 20 | ## Next Steps 21 | 22 | [Modules]({{ site.baseurl }}{% link en/plus/guide/modules.md %}) 23 | {: .btn-stylized} 24 | -------------------------------------------------------------------------------- /en/plus/guide/server-apps-overview.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: page 3 | title: Overviews | Guide | PM2 Plus Documentation 4 | menu: starter 5 | lang: en 6 | section: plus 7 | permalink: "/en/plus/guide/server-apps-overview/" 8 | --- 9 | 10 | # Presentation 11 | 12 | There are 2 types of overview in PM2 Plus, the first one is the `Application overview` where you don't see any reference to a server in the overview, this one is mainly useful to containers or environment with a lot of applications. 13 | The other one is the `Server overview` which is the default with PM2 Plus, it's more detailed than the other one and show you every information by physical server. 14 | 15 | ## Server Overview 16 | 17 | ![server overview](https://cdn.jsdelivr.net/gh/keymetrics/branding/screenshots/plus/overview/server_overview.png) 18 | 19 | This view is breakdown by server, in the following example we have one server with 7 applications: 20 | 21 | ![detailed example]({{ site.baseurl }}{% link img/plus/server.png %}) 22 | 23 | In the top bar of this section you will find infos about the actual server 24 | - The Server's Name 25 | - Number of cores and memory 26 | - Versions of Node.js & PM2 27 | - The public and private IP 28 | 29 | You are able to get realtime infos about any application such as 30 | - cpu utilization 31 | - memory comsumption 32 | - HTTP Latency 33 | - Issues 34 | - Event Loop Lag (the amount of time between two run of the event loop, should be less than 10 ms) 35 | - Number of restarts 36 | - Versionning metadata (if your app is in a git repository) 37 | 38 | At the left of each application you can toggle more information for the application, it will show you: 39 | - All the metrics about the applications (both default and custom ones) 40 | - All the custom actions you added, you can trigger them for these buttons too. 41 | 42 | ## Apps Overview 43 | 44 | ![app overview](https://cdn.jsdelivr.net/gh/keymetrics/branding/screenshots/plus/overview/app_overview.png) 45 | 46 | It contains almost everything you need to see to understand the current health of your applications: 47 | 48 | - CPU Usage Heatmap 49 | - Each cell represent a process in a server 50 | - the color represent the cpu usage (varying from green to red where red is 100% of cpu usage) 51 | - Error history 52 | - Last hour, last day and last week, it give you an idea if the application is instable for a long time or not. 53 | - Important metrics 54 | - average cpu utilization 55 | - average memory consumption 56 | - average latency (only if you are using an http server) 57 | - average Request / minutes (only if you are using an http server) 58 | 59 | If you click on the heatmap, you will directly go on the app dashboad which is discribed in the following dashboard. 60 | 61 | ## Next Steps 62 | 63 | [Application dashboard]({{ site.baseurl }}{% link en/plus/guide/app-dashboard.md %}) 64 | {: .btn-stylized} 65 | -------------------------------------------------------------------------------- /en/plus/integration/README.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: page 3 | title: Integration | PM2 Plus Documentation 4 | menu: starter 5 | lang: en 6 | section: plus 7 | hide_comments: true 8 | permalink: "/en/plus/integration/" 9 | --- 10 | 11 | # Integration 12 | 13 | This section will help you integrate PM2 Plus. 14 | 15 | Pick the tutorial that best matches your needs: 16 | 17 | - [AWS Elastic Beanstalk]({{ site.baseurl }}{% link en/plus/integration/elastic-beanstalk.md %}) 18 | - [Docker]({{ site.baseurl }}{% link en/plus/integration/docker.md %}) 19 | - [Heroku]({{ site.baseurl }}{% link en/plus/integration/heroku.md %}) 20 | - [With a Cloud Provider]({{ site.baseurl }}{% link en/plus/integration/cloud-providers.md %}) 21 | -------------------------------------------------------------------------------- /en/plus/integration/cloud-providers.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: page 3 | title: Cloud Providers | Integration | PM2 Plus Documentation 4 | menu: starter 5 | lang: en 6 | section: plus 7 | permalink: "/en/plus/integration/cloud-providers/" 8 | --- 9 | 10 | # Monitor your Node.js app in a cloud provider 11 | 12 | In seconds, this tutorial will show you how to monitor a Node.js application with PM2 Plus in a cloud provider. 13 | 14 | We assume that your app has already been wrapped with PM2. If not, follow the [PM2 Cloud Provider Tutorial]({{ site.baseurl }}{% link en/runtime/integration/cloud-providers.md %}). 15 | 16 | ## Create an account 17 | 18 | Register [here](https://id.keymetrics.io/api/oauth/register). 19 | 20 | ## Link your app with PM2 Plus 21 | 22 | In order to connect PM2 to the dashboard, you need to add your public and private keys in the environment. 23 | 24 | ```bash 25 | export PM2_PUBLIC_KEY="YYYYY" 26 | export PM2_SECRET_KEY="XXXXXXXXX" 27 | pm2 update 28 | ``` 29 | 30 | ## Set the server name in PM2 Plus 31 | 32 | Set the `PM2_MACHINE_NAME` environment variable to specify a server name: 33 | 34 | ```bash 35 | export PM2_MACHINE_NAME="my-cloud-provider-server" 36 | ``` 37 | 38 | The default server name is the hostname (`HOST` environment variable) with a random string. 39 | {: .tip} 40 | 41 | Be careful, in case of duplicate hostnames the dashboard will receive data from both instances and flicker. 42 | {: .tip} 43 | 44 | ## Next Steps 45 | 46 | Complete your [dashboard configuration]({{ site.baseurl }}{% link en/plus/guide/configuration.md %}). 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /en/plus/integration/docker.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: page 3 | title: Docker | Integration | PM2 Plus Documentation 4 | menu: starter 5 | lang: en 6 | section: plus 7 | permalink: "/en/plus/integration/docker/" 8 | --- 9 | 10 | # Monitor your Node.js app in a Docker container 11 | 12 | In seconds, this tutorial will show you how to monitor a Node.js application with PM2 Plus inside a container. 13 | 14 | We assume that your app has already been wrapped with PM2. If not, follow the [PM2 Docker Tutorial]({{ site.baseurl }}{% link en/runtime/integration/docker.md %}). 15 | 16 | ## Create an account 17 | 18 | Register [here](https://id.keymetrics.io/api/oauth/register). 19 | 20 | ## Install the profiler 21 | 22 | Add this to your Dockerfile to install the profiler: 23 | 24 | ```Dockerfile 25 | RUN pm2 install profiler 26 | ``` 27 | 28 | ## Link your app with PM2 Plus 29 | 30 | In order to connect PM2 to the dashboard, you need to add your public and private keys in the environment. 31 | 32 | Create a .env file with: 33 | ```.env 34 | PM2_SECRET_KEY=XXXXX 35 | PM2_PUBLIC_KEY=YYYYY 36 | ``` 37 | and restart your container with `docker run`adding `--env-file .env` to load the environment variables. 38 | 39 | ## Set the server name in PM2 Plus 40 | 41 | Set the `PM2_MACHINE_NAME` environment variable to specify a server nam. Add this to the .env file: 42 | 43 | ```.env 44 | PM2_SECRET_KEY=XXXXX 45 | PM2_PUBLIC_KEY=YYYYY 46 | PM2_MACHINE_NAME=docker-server 47 | ``` 48 | 49 | The default server name is the hostname (`HOST` environment variable) with a random string. 50 | {: .tip} 51 | 52 | Be careful, in case of duplicate hostnames the dashboard will receive data from both instances and flicker. 53 | {: .tip} 54 | 55 | ## Next Steps 56 | 57 | Complete your dashboard [configuration]({{ site.baseurl }}{% link en/plus/guide/configuration.md %}). 58 | 59 | 60 | 61 | -------------------------------------------------------------------------------- /en/plus/integration/elastic-beanstalk.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: page 3 | title: Elastic Beanstalk | Integration | PM2 Plus Documentation 4 | menu: starter 5 | lang: en 6 | section: plus 7 | permalink: "/en/plus/integration/elastic-beanstalk/" 8 | --- 9 | 10 | # Monitor your Node.js app in AWS Elastic Beanstalk 11 | 12 | In seconds, this tutorial will show you how to monitor a Node.js application with PM2 Plus in AWS Elastic Beanstalk. 13 | 14 | We assume that your app has already been wrapped with PM2. If not, follow our [PM2 AWS Elastic Beanstalk Tutorial]({{ site.baseurl }}{% link en/runtime/integration/elastic-beanstalk.md %}). 15 | 16 | ## Create an account on PM2 Plus 17 | 18 | You can register [here](https://id.keymetrics.io/api/oauth/register). 19 | 20 | ## Link your app with PM2 Plus 21 | 22 | In order to connect PM2 to the dashboard, you need to add your public and private keys in the environment. 23 | 24 | Inject your keys into your eb environment: 25 | ```bash 26 | eb setenv PM2_PUBLIC_KEY=YYYYY PM2_SECRET_KEY=XXXXXXXX 27 | ``` 28 | 29 | You can access your keys at the top right of your dashboard 30 | {: .tip} 31 | 32 | We unadvise to use the ecosystem file to set your keys into your environment, doing so your ecosystem file can stay public 33 | {: .warn} 34 | 35 | ## Set the server name in PM2 Plus 36 | 37 | Set the `PM2_MACHINE_NAME` environment variable to specify a server name: 38 | 39 | ```bash 40 | eb setenv PM2_MACHINE_NAME=aws-eb-server 41 | ``` 42 | 43 | The default server name is the hostname (`HOST` environment variable) with a random string. 44 | {: .tip} 45 | 46 | Be careful, in case of duplicate hostnames the dashboard will receive data from both instances and flicker. 47 | {: .tip} 48 | 49 | ## Next Steps 50 | 51 | Complete your [dashboard configuration]({{ site.baseurl }}{% link en/plus/guide/configuration.md %}). 52 | 53 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /en/plus/integration/heroku.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: page 3 | title: Heroku | Integration | PM2 Plus Documentation 4 | menu: starter 5 | lang: en 6 | section: plus 7 | permalink: "/en/plus/integration/heroku/" 8 | --- 9 | 10 | # Monitor your Node.js app in Heroku 11 | 12 | In seconds, this tutorial will show you how to monitor a Node.js application with PM2 Plus in Heroku. 13 | 14 | We assume that your app has already been wrapped with PM2. If not, follow the [PM2 Heroku Tutorial]({{ site.baseurl }}{% link en/runtime/integration/heroku.md %}). 15 | 16 | ## Create an account 17 | 18 | Register [here](https://id.keymetrics.io/api/oauth/register). 19 | 20 | ## Link with PM2 Plus 21 | 22 | In order to connect PM2 to the dashboard, you need to add your public and private keys in the environment. 23 | 24 | To add your keys, run: 25 | 26 | ```bash 27 | heroku config:set PM2_PUBLIC_KEY=XXXXXXXXXX PM2_SECRET_KEY=YYYYY 28 | ``` 29 | 30 | You can access your keys at the top right of your dashboard 31 | {: .tip} 32 | 33 | ## Set the server name in PM2 Plus 34 | 35 | Set the `PM2_MACHINE_NAME` environment variable to specify a server name: 36 | 37 | ```bash 38 | heroku config:set PM2_MACHINE_NAME=heroku-server 39 | ``` 40 | 41 | The default server name is the hostname (`HOST` environment variable) with a few random characters. 42 | {: .tip} 43 | 44 | Be careful, in case of duplicate hostnames the dashboard will receive data from both instances and flicker. 45 | {: .tip} 46 | 47 | ## Next Steps 48 | 49 | Complete your [dashboard configuration]({{ site.baseurl }}{% link en/plus/guide/configuration.md %}). 50 | 51 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /en/plus/integration/now.md: -------------------------------------------------------------------------------- 1 | Now.sh is actually not supported by pm2 2 | {: .warn} 3 | 4 | # Monitor your Node.js app in Now.sh 5 | 6 | In seconds, this tutorial will show you how to monitor a node.js application with PM2 Plus and Now.sh. 7 | 8 | We assume that your app has already been wrapped with pm2. If not, follow the [PM2 Now.sh Tutorial]({{ site.baseurl }}{% link en/runtime/integration/now.md %}). 9 | 10 | --- 11 | 12 | ### Create an account 13 | 14 | Register [here](https://id.keymetrics.io/api/oauth/register). 15 | 16 | --- 17 | 18 | ### Link with pm2 Plus 19 | 20 | You first need to use pm2 to wrap your app inside your Docker container. If not, follow the [now.sh tutorial]({{ site.baseurl }}{% link en/runtime/integration/now.md %}). 21 | 22 | ### Link with pm2 Plus 23 | 24 | In order to connect pm2 to your dashboard, you must add your public and private keys in the environment. 25 | 26 | Add a `KEYMETRICS_PUBLIC` and a `KEYMETRICS_SECRET` environment variables and fill their value with your keys. 27 | 28 | You can access your keys at the top right of your dashboard 29 | {: .tip} 30 | 31 | ### Set the server name in pm2 Plus 32 | 33 | Add a `PM2_MACHINE_NAME` environment variable to the ecosystem file to specify a server name: 34 | 35 | ```javascript 36 | module.exports = { 37 | apps : [{ 38 | name: "app", 39 | script: "./app.js", 40 | instances: "max", 41 | env: { 42 | NODE_ENV: "development", 43 | }, 44 | env_production: { 45 | NODE_ENV: "production", 46 | PM2_MACHINE_NAME: "now-my-app", 47 | } 48 | }] 49 | } 50 | ``` 51 | 52 | The default server name is the hostname (`HOST` variable) with a few random characters. 53 | {: .tip} 54 | 55 | Be careful, in case of duplicate hostnames the dashboard will receive data from both instances and flicker. 56 | {: .tip} 57 | 58 | ### Next Steps 59 | 60 | Complete your [dashboard configuration]({{ site.baseurl }}{% link en/plus/guide/configuration.md %}). 61 | 62 | 63 | 64 | 65 | -------------------------------------------------------------------------------- /en/plus/quick-start.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: page 3 | title: Installation | PM2 Plus Documentation 4 | menu: starter 5 | lang: en 6 | section: plus 7 | permalink: "/en/plus/quick-start/" 8 | --- 9 | 10 | # Installation 11 | 12 | In seconds, this Installation tutorial will show you how to start monitoring your Node.js application with PM2 Plus. 13 | 14 | ## Create an account 15 | 16 | You can create a PM2 plus account by registering [here](https://id.keymetrics.io/api/oauth/register) or juste by typing ```pm2 plus``` in your terminal. 17 | 18 | Then just simply follow the in-app tutorial 19 | ![Wizard](https://raw.githubusercontent.com/keymetrics/branding/master/screenshots/plus/wizard/step1.png) 20 | 21 | 22 | ## Connect your server to the dashboard 23 | 24 | Connect your server to your dashboard and start collecting metrics with: 25 | 26 | ```bash 27 | pm2 link 28 | ``` 29 | 30 | Or, if you don't have access to the CLI, add `PM2_PUBLIC_KEY` and `PM2_SECRET_KEY` environment variables set with your public and private keys. 31 | 32 | Use the `connect` button on the top right of your dashboard to find your `PM2_PUBLIC_KEY` and `PM2_SECRET_KEY` 33 | {: .tip} 34 | 35 | 36 | ## You are done 37 | 38 | Go back to the dashboard, you will have access to realtime metrics of your app. 39 | 40 | ![dashboard view](https://raw.githubusercontent.com/keymetrics/branding/master/screenshots/plus/overview/server_overview.png) 41 | 42 | ## Next Steps 43 | 44 | [Discover the Dashboard]({{ site.baseurl }}{% link en/plus/guide/server-apps-overview.md %}) 45 | {: .btn-stylized} 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /en/runtime/best-practices/README.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: page 3 | title: Best Practices | PM2 Documentation 4 | menu: starter 5 | lang: en 6 | section: runtime 7 | hide_comments: true 8 | permalink: "/en/runtime/best-practices/" 9 | --- 10 | 11 | # Production Best Practices 12 | 13 | This section gathers production best practices to make your app scalable from the beginning: 14 | 15 | - [Environment Variables in Node.js]({{ site.baseurl }}{% link en/runtime/best-practices/environment-variables.md %}) 16 | - [Graceful Shutdown]({{ site.baseurl }}{% link en/runtime/best-practices/graceful-shutdown.md %}) 17 | - [Stateless Application]({{ site.baseurl }}{% link en/runtime/best-practices/stateless-application.md %}) 18 | -------------------------------------------------------------------------------- /en/runtime/best-practices/stateless-application.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: page 3 | title: Stateless Application | Best Practices | PM2 Documentation 4 | menu: starter 5 | lang: en 6 | section: runtime 7 | permalink: "/en/runtime/best-practices/stateless-application/" 8 | --- 9 | 10 | # Stateless Application 11 | 12 | A stateless application has no local data stored in the process. For example, sessions/websocket connections, session-memory and related. 13 | 14 | You must use Redis, Mongo or other databases to share all states between processes. 15 | 16 | A useful resource on how to write efficient, production ready stateless application is The Twelve Factor Application manifesto: 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /en/runtime/features/#memory-limit.md#: -------------------------------------------------------------------------------- 1 | --- 2 | layout: page 3 | title: Memory Threshold Auto Reload | Features | PM2 Documentation 4 | description: Fast way to temporarily fix memory leaks 5 | lang: en 6 | section: runtime 7 | permalink: /en/runtime/features/memory-limit 8 | --- 9 | 10 | ## Max Memory Threshold Auto Reload 11 | 12 | PM2 allows to reload (auto fallback to restart if not in cluster) an application based on a memory limit/ Please note that the PM2 internal worker (which checks memory), starts every 30 seconds, so you may have to wait a bit before your process gets restarted automatically after reaching the memory threshold. 13 | 14 | CLI: 15 | 16 | ```bash 17 | pm2 start api.js --max-memory-restart 300M 18 | ``` 19 | 20 | Config file (ecosystem.config.js): 21 | 22 | ```javascript 23 | module.exports = { 24 | apps: [{ 25 | name: 'api', 26 | script: 'api.js', 27 | max_memory_restart: '300M' 28 | }] 29 | } 30 | ``` 31 | 32 | *Note:* Units can be K(ilobyte), M(egabyte), G(igabyte). 33 | -------------------------------------------------------------------------------- /en/runtime/features/commands-cheatsheet.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: page 3 | title: Commands Cheatsheet | PM2 Documentation 4 | description: PM2 Inception 5 | lang: en 6 | section: runtime 7 | permalink: "/en/runtime/features/commands-cheatsheet/" 8 | --- 9 | 10 | ## CheatSheet 11 | 12 | Here is a quick, pragmatic overview of a range of PM2 commands: 13 | 14 | ### Install 15 | 16 | ```bash 17 | $ npm install pm2 -g 18 | ``` 19 | 20 | ### Start an app 21 | 22 | ```bash 23 | $ pm2 start app.js 24 | ``` 25 | 26 | ### Start and auto-restart on file change 27 | 28 | ```bash 29 | $ pm2 start app.js --watch [--ignore-watch /*/] 30 | ``` 31 | 32 | ### List apps 33 | 34 | ```bash 35 | pm2 list 36 | ``` 37 | 38 | ### Show extended infos 39 | 40 | ```bash 41 | $ pm2 show 42 | ``` 43 | 44 | ### Restart 45 | 46 | ```bash 47 | $ pm2 restart app 48 | ``` 49 | 50 | ### Restart and update env 51 | 52 | ```bash 53 | $ NODE_ENV=production pm2 restart app --update-env 54 | ``` 55 | 56 | ### Stop 57 | 58 | ```bash 59 | $ pm2 stop app 60 | ``` 61 | 62 | ### Delete 63 | 64 | ```bash 65 | $ pm2 delete app 66 | ``` 67 | 68 | ### Show logs 69 | 70 | ```bash 71 | $ pm2 logs 72 | ``` 73 | 74 | ### Show env 75 | 76 | ```bash 77 | $ pm2 env 78 | ``` 79 | 80 | ### Start PM2 at boot 81 | 82 | ```bash 83 | $ pm2 startup 84 | ``` 85 | 86 | ### Set a name 87 | 88 | ```bash 89 | $ pm2 start app.js --name="name" 90 | # or update name 91 | $ pm2 restart app --name="new-name" 92 | ``` 93 | 94 | ### Reset Restart Counters 95 | 96 | ```bash 97 | $ pm2 reset all 98 | ``` 99 | 100 | ### Monitoring 101 | 102 | ```bash 103 | $ pm2 monitor 104 | ``` 105 | 106 | ### Dump all process data 107 | 108 | ```bash 109 | $ pm2 prettylist 110 | # or 111 | $ pm2 show 112 | ``` 113 | -------------------------------------------------------------------------------- /en/runtime/features/memory-limit.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: page 3 | title: Memory Threshold Auto Reload | Features | PM2 Documentation 4 | description: Fast way to temporarily fix memory leaks 5 | lang: en 6 | section: runtime 7 | permalink: "/en/runtime/features/memory-limit/" 8 | --- 9 | 10 | ## Max Memory Threshold Auto Reload 11 | 12 | PM2 allows to reload (auto fallback to restart if not in cluster) an application based on a memory limit/ Please note that the PM2 internal worker (which checks memory), starts every 30 seconds, so you may have to wait a bit before your process gets restarted automatically after reaching the memory threshold. 13 | 14 | CLI: 15 | 16 | ```bash 17 | pm2 start api.js --max-memory-restart 300M 18 | ``` 19 | 20 | Config file (ecosystem.config.js): 21 | 22 | ```bash 23 | module.exports = { 24 | apps: [{ 25 | name: 'api', 26 | script: 'api.js', 27 | max_memory_restart: '300M' 28 | }] 29 | } 30 | ``` 31 | 32 | *Note:* Units can be K(ilobyte), M(egabyte), G(igabyte). 33 | -------------------------------------------------------------------------------- /en/runtime/features/multiple-pm2.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: page 3 | title: Multiple PM2 Runtime | Features | PM2 Documentation 4 | description: PM2 Inception 5 | lang: en 6 | section: runtime 7 | permalink: "/en/runtime/features/multiple-pm2/" 8 | --- 9 | 10 | ## Running Multiple PM2 11 | 12 | If you want to run multiple PM2 under the same user, you can override the variable `PM2_HOME`. Setting the PM2_HOME will change the PM2 configuration folder, like communication sockets (`$HOME/.pm2/pub.sock` and `$HOME/.pm2/rpc.sock`), default logs location path, pids and so on. 13 | 14 | ```javascript 15 | PM2_HOME=/tmp/.pm2 pm2 start echo.js 16 | PM2_HOME=/tmp/.pm3 pm2 start echo.js 17 | ``` 18 | -------------------------------------------------------------------------------- /en/runtime/features/restart-strategies.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: page 3 | title: Restart Strategies | Features | PM2 Documentation 4 | description: Different Restart Strategies in case of crash 5 | lang: en 6 | section: runtime 7 | permalink: "/en/runtime/features/restart-strategies/" 8 | --- 9 | 10 | ## Exponential Backoff Restart Delay 11 | 12 | *Available in PM2 >= 3.2* 13 | 14 | A new restart mode has been implemented on PM2 Runtime, making your application restarts in a smarter way. Instead of restarting your application like crazy when exceptions happens (e.g. database is down), the *exponential backoff restart* will increase incrementaly the time between restarts, reducing the pressure on your DB or your external provider... Pretty easy to use: 15 | 16 | CLI: 17 | ```bash 18 | $ pm2 start app.js --exp-backoff-restart-delay=100 19 | ``` 20 | 21 | Or via ecosystem.config.js file: 22 | ```javascript 23 | module.exports = [{ 24 | script: 'app.js', 25 | exp_backoff_restart_delay: 100 26 | }] 27 | ``` 28 | 29 | When an application crash unexpectedly and the option `--exp-backoff-restart-delay` is activated, you will be able to see a new application status **waiting restart**. 30 | 31 | By running `pm2 logs` you will also see the restart delay being incremented: 32 | ``` 33 | PM2 | App [throw:0] will restart in 100ms 34 | PM2 | App [throw:0] exited with code [1] via signal [SIGINT] 35 | PM2 | App [throw:0] will restart in 150ms 36 | PM2 | App [throw:0] exited with code [1] via signal [SIGINT] 37 | PM2 | App [throw:0] will restart in 225ms 38 | ``` 39 | 40 | As you can see the restart delay between restarts will increase in an exponential moving average, till reaching the maximum of 15000ms between restarts. 41 | 42 | When the application will then get back to a stable mode (uptime without restarts of more than 30 seconds), the restart delay will automatically reset to 0ms. 43 | 44 | ## Fixed Restart Delay 45 | 46 | *Available in PM2 >= 0.9* 47 | 48 | You can also use the `restart_delay` to set a fixed timing between restarts: 49 | 50 | CLI: 51 | ```bash 52 | $ pm2 start app.js --restart-delay=3000 53 | ``` 54 | 55 | Or via ecosystem.config.js file: 56 | ```javascript 57 | module.exports = [{ 58 | script: 'app.js', 59 | restart_delay: 3000 60 | }] 61 | ``` 62 | 63 | ## Memory based reload strategy 64 | 65 | Checkout [https://pm2.io/doc/en/runtime/features/memory-limit/](https://pm2.io/doc/en/runtime/features/memory-limit/) 66 | 67 | ## 0second Downtime Reload 68 | 69 | Checkout the cluster mode to get [this behavior](/doc/en/runtime/guide/load-balancing/#0-seconds-downtime-reload) 70 | 71 | ## No Auto Restart 72 | 73 | This is useful in case we wish to run 1-time scripts and don't want the process manager to restart our script in case it's completed running. 74 | 75 | Simply running these scripts from bash would terminate the script in case the ssh-session is terminated and the script should not get restarted when it completes execution. 76 | 77 | PM2 is perfect for such cases, providing robust monitoring and logging 78 | 79 | CLI: 80 | ```bash 81 | $ pm2 start app.js --no-autorestart 82 | ``` 83 | -------------------------------------------------------------------------------- /en/runtime/features/source-maps.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: page 3 | title: Memory Threshold Auto Reload | Features | PM2 Documentation 4 | description: Set a memory limit and allow soft reloads without downtime 5 | lang: en 6 | section: runtime 7 | permalink: "/en/runtime/features/javascript-source-maps/" 8 | --- 9 | 10 | ## Source Map 11 | 12 | If you use [BabelJS](https://babeljs.io/), [Typescript](http://www.typescriptlang.org/) or any other Javascript superset you may have noticed that when an exception occurs, the stacktrace is not meaningful at all. To get interesting informations you need to generate [source map files](http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/). 13 | 14 | Once these source map files are generated, PM2 will automatically detects them and will help you inspect errors. 15 | 16 | **PM2 automatically detects javascript source map files** if the file you start (let's say app.js) has his map equivalence (e.g app.js.map). 17 | 18 | ### Inspect exceptions 19 | 20 | Exceptions are logged into your application error log file. 21 | 22 | To check your logs to detect exceptions, you simply have to type: 23 | 24 | ```bash 25 | pm2 logs main 26 | ``` 27 | 28 | Or use PM2+ to get emailed and get exceptions analysis when it happens 29 | 30 | ### Disable source map support 31 | 32 | If you do not want PM2 to automatically support javascript source map you can use the option `--disable-source-map-support`. 33 | 34 | It can be done both via CLI and via JSON file. 35 | -------------------------------------------------------------------------------- /en/runtime/features/updating-pm2.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: page 3 | title: Updating PM2 | Features | PM2 Documentation 4 | description: Updating is a matter of 3 commands 5 | lang: en 6 | section: runtime 7 | permalink: "/en/runtime/features/updating-pm2/" 8 | --- 9 | 10 | ## Updating PM2 11 | 12 | Updating PM2 is straightforward. Upgrading between minor and patch versions will **never** break anything on your environment 13 | 14 | You will have to first run the installation command: 15 | 16 | ```bash 17 | $ npm install pm2@latest -g 18 | ``` 19 | 20 | Then to save your current process list, kill the previous PM2 daemon and restore process list with the new PM2 version is as easy as doing: 21 | 22 | ```bash 23 | $ pm2 update 24 | ``` 25 | -------------------------------------------------------------------------------- /en/runtime/features/watch-restart.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: page 3 | title: Watch & Restart | Features | PM2 Documentation 4 | description: Watch & Restart application on file change 5 | lang: en 6 | section: runtime 7 | permalink: "/en/runtime/features/watch-restart/" 8 | --- 9 | 10 | ## Auto restart apps on file change 11 | 12 | PM2 can automatically restart your application when a file is modified in the current directory or its subdirectories: 13 | 14 | ```bash 15 | pm2 start app.js --watch 16 | ``` 17 | 18 | If `--watch` is enabled, stopping it won't stop watching: 19 | 20 | - `pm2 stop 0` will not stop watching 21 | - `pm2 stop 0 --watch` will stop watching 22 | 23 | Restart with `--watch` will toggle the `watch` parameter. 24 | 25 | To watch specific paths, please use a [Ecosystem File](/doc/en/runtime/guide/ecosystem-file/), `watch` can take a string or an array of paths. Default is `true`: 26 | 27 | ```javascript 28 | module.exports = { 29 | apps: [{ 30 | script: "app.js", 31 | watch: ["server", "client"], 32 | // Delay between restart 33 | watch_delay: 1000, 34 | ignore_watch : ["node_modules", "client/img"], 35 | watch_options: { 36 | "followSymlinks": false 37 | } 38 | }] 39 | } 40 | ``` 41 | 42 | Notes: 43 | 44 | `watch_options` is an object that will replace options given to chokidar. Please refer to [chokidar documentation](https://github.com/paulmillr/chokidar#api) for the definition. 45 | 46 | PM2 is giving chokidar these Default options: 47 | 48 | ``` 49 | var watch_options = { 50 | persistent : true, 51 | ignoreInitial : true 52 | } 53 | ``` 54 | -------------------------------------------------------------------------------- /en/runtime/guide/development-tools.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: page 3 | title: Development Tools | Guide | PM2 Documentation 4 | menu: starter 5 | lang: en 6 | section: runtime 7 | permalink: "/en/runtime/guide/development-tools/" 8 | --- 9 | 10 | # Development Tools 11 | 12 | PM2 comes with two development tools that will help you on the development stage: a watch and restart mode and a server for static files. 13 | 14 | ## Watch and Restart 15 | 16 | The watch and restart mode watches the current directory to detect file changes and auto-start. 17 | 18 | This mode can be enable in your ecosystem.config.js: 19 | 20 | ```javascript 21 | module.exports = { 22 | apps : [{ 23 | name: "app", 24 | script: "./app.js", 25 | watch: true, 26 | }] 27 | } 28 | ``` 29 | 30 | Beware that the watch and restart mode makes hard restart, without sending SIGINT. 31 | {: .tip} 32 | 33 | ### Watch options 34 | 35 | You can use advanced options to specify path to watch or path to ignore. 36 | 37 | ```javascript 38 | module.exports = { 39 | apps : [{ 40 | name: "app", 41 | script: "./app.js", 42 | watch: ".", 43 | }] 44 | } 45 | ``` 46 | 47 | - `watch` can also be a string or an array of paths to watch. Current directory is watched when set to `true`. 48 | - `ignore_watch` can be an array of paths or a string. It is used by the [chokidar](https://github.com/paulmillr/chokidar#path-filtering) dependency as a glob or a regular expression. 49 | - `watch_options` is an object that is given as options to [chokidar](https://github.com/paulmillr/chokidar#api) dependency (default options used by pm2 are persistent and ignoreInitial set to true) 50 | 51 | When working with NFS devices you'll need to set `usePolling: true` as stated in [this chokidar issue](https://github.com/paulmillr/chokidar/issues/242). 52 | 53 | ### With CLI 54 | 55 | Watch mode can also be enabled via CLI with 56 | 57 | ```bash 58 | pm2 start app.js --watch 59 | ``` 60 | 61 | However, please note that when `--watch` is enabled, you must use `pm2 stop --watch ` to stop the process, as simple stop won't stop the watching. 62 | 63 | ## Serve static file over HTTP 64 | 65 | pm2 can serve static files (like a frontend app) over HTTP with: 66 | 67 | ```bash 68 | pm2 serve 69 | ``` 70 | 71 | As default values are `current folder` and `8080`, you can then just use: 72 | 73 | ```bash 74 | pm2 serve 75 | ``` 76 | 77 | In the ecosystem file: 78 | 79 | ```javascript 80 | module.exports = { 81 | apps: [{ 82 | name: "static-file", 83 | script: "serve", 84 | env: { 85 | PM2_SERVE_PATH: ".", 86 | PM2_SERVE_PORT: 8080, 87 | }, 88 | }] 89 | } 90 | ``` 91 | 92 | and start with: 93 | 94 | ```bash 95 | pm2 start ecosystem.config.js 96 | ``` 97 | 98 | All other pm2 options are still available. 99 | {: .tip} 100 | 101 | ## Next Steps 102 | 103 | [Easy Deploy with SSH]({{ site.baseurl }}{% link en/runtime/guide/easy-deploy-with-ssh.md %}) 104 | {: .btn-stylized} 105 | -------------------------------------------------------------------------------- /en/runtime/guide/ecosystem-file.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: page 3 | title: Ecosystem File | Guide | PM2 Documentation 4 | menu: starter 5 | lang: en 6 | section: runtime 7 | permalink: "/en/runtime/guide/ecosystem-file/" 8 | --- 9 | 10 | # Ecosystem File 11 | 12 | When deploying on multiple servers or when using multiple CLI arguments, an alternative to the command line becomes more convenient for starting your apps. 13 | 14 | The purpose of the ecosystem file is to gather all options and environment variables for all your applications. 15 | 16 | ## Generate a template 17 | 18 | Generate an `ecosystem.config.js` template with: 19 | 20 | ```bash 21 | pm2 ecosystem 22 | ``` 23 | 24 | This will generate: 25 | 26 | ```javascript 27 | module.exports = { 28 | apps : [{ 29 | name: "app", 30 | script: "./app.js", 31 | env: { 32 | NODE_ENV: "development", 33 | }, 34 | env_production: { 35 | NODE_ENV: "production", 36 | } 37 | }] 38 | } 39 | ``` 40 | 41 | For more information about available properties, check the [ecosystem file reference]({{ site.baseurl }}{% link en/runtime/reference/ecosystem-file.md %}). 42 | 43 | ## Use your ecosystem file 44 | 45 | ### Routine 46 | 47 | Inside your source code working directory, you can add all of the applications to your process list with: 48 | 49 | ```bash 50 | pm2 start 51 | ``` 52 | 53 | This will run all of the `apps` defined within the `ecosystem.config.js` generated with `pm2 init`. 54 | 55 | You can also load an ecosystem from an other folder with: 56 | 57 | ```bash 58 | pm2 start /path/to/ecosystem.config.js 59 | ``` 60 | 61 | ### Only use a specific app 62 | 63 | Use your ecosystem file only on a specific application with the option `--only `: 64 | 65 | ```bash 66 | pm2 start --only app 67 | ``` 68 | 69 | ## Environment variables 70 | 71 | You can declare variables for multiple environments. Each enviroment key must have this format: `env_`. 72 | 73 | For example, the following `app` process can be started in two environments: `development` and `production`. 74 | 75 | ```javascript 76 | module.exports = { 77 | apps : [{ 78 | name: "app", 79 | script: "./app.js", 80 | env: { 81 | NODE_ENV: "development", 82 | }, 83 | env_production: { 84 | NODE_ENV: "production", 85 | } 86 | }] 87 | } 88 | ``` 89 | 90 | To start this `app` in a particular environment, use the `--env` flag: 91 | 92 | ```bash 93 | pm2 start ecosystem.config.js # uses variables from `env` 94 | pm2 start ecosystem.config.js --env production # uses variables from `env_production` 95 | ``` 96 | 97 | ### Options Reference 98 | 99 | To know more about all the options available checkout [the complete option reference](https://pm2.io/doc/en/runtime/reference/ecosystem-file/) 100 | 101 | ## Next Steps 102 | 103 | [Process Management]({{ site.baseurl }}{% link en/runtime/guide/process-management.md %}) 104 | {: .btn-stylized} 105 | -------------------------------------------------------------------------------- /en/runtime/guide/entrypoint.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: page 3 | title: Entrypoint | Guide | PM2 Documentation 4 | menu: starter 5 | lang: en 6 | section: runtime 7 | permalink: "/en/runtime/guide/entrypoint/" 8 | --- 9 | 10 | # Entrypoint 11 | 12 | The **entrypoint.js** lets you precisely contol your application flow and organize the link between the Node.js runtime and PM2. 13 | 14 | ## Entrypoint base class 15 | 16 | The entrypoint has 4 methods; onStart, onStop, sensors and actuators. Here is an example of this class: 17 | 18 | ```javascript 19 | const Entrypoint = require('@pm2/io').Entrypoint 20 | 21 | new class App extends Entrypoint { 22 | // This is the very first method called on startup 23 | onStart (cb) { 24 | 25 | // Returning the callback will tell PM2 that the app is ready to process queries 26 | return cb() 27 | } 28 | 29 | // This is the very last method called on exit || uncaught exception 30 | onStop(err, cb, code, signal) { 31 | } 32 | 33 | // Here we declare some process metrics 34 | sensors () { 35 | } 36 | 37 | // Here are some actions to interact with the app in live 38 | actuators () { 39 | } 40 | } 41 | ``` 42 | 43 | ## Example 44 | 45 | Here is a concrete example for a simple Hello world http api: 46 | 47 | ```javascript 48 | const io = require('@pm2/io') 49 | const app = require('express')() 50 | 51 | new class MyApp extends io.Entrypoint { 52 | // This is the very first method called on startup 53 | onStart (cb) { 54 | const http = require('http').Server(app) 55 | 56 | app.get('/', (req, res) => { 57 | this.reqMeter.mark() 58 | res.send('Hello From Entrypoint.js') 59 | }); 60 | 61 | this.server = app.listen(cb) 62 | } 63 | 64 | // This is the very last method called on exit || uncaught exception 65 | onStop (err, cb, code, signal) { 66 | console.log(`App has exited with code ${code}`) 67 | } 68 | 69 | // Here we declare some process metrics 70 | sensors () { 71 | this.reqMeter = this.io.meter('req/min') 72 | } 73 | 74 | // Here are some actions to interact with the app in live 75 | actuators () { 76 | this.io.action('getEnv', (reply) => { 77 | reply({ server: this.server }) 78 | }) 79 | } 80 | } 81 | ``` 82 | 83 | Then to start it just run: 84 | 85 | ``` 86 | pm2 start entrypoint.js 87 | ``` 88 | 89 | ## Roadmap 90 | 91 | We plan to implement ecosystem file configuration straight into this entrypoint.js file, if you have any remarks, ideas or feedback feel free to [post an issue](https://github.com/Unitech/pm2) 92 | -------------------------------------------------------------------------------- /en/runtime/guide/installation.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: page 3 | title: Installation | Guide | PM2 Documentation 4 | menu: starter 5 | lang: en 6 | section: runtime 7 | permalink: "/en/runtime/guide/installation/" 8 | --- 9 | 10 | # Installation 11 | 12 | ## Install pm2 13 | 14 | With yarn: 15 | ```bash 16 | yarn global add pm2 17 | ``` 18 | 19 | With npm: 20 | ```bash 21 | npm install pm2 -g 22 | ``` 23 | 24 | With debian, use the install script: 25 | ```bash 26 | apt update && apt install sudo curl && curl -sL https://raw.githubusercontent.com/Unitech/pm2/master/packager/setup.deb.sh | sudo -E bash - 27 | ``` 28 | 29 | With docker, follow this [tutorial]({{ site.baseurl }}{% link en/runtime/integration/docker.md %}). 30 | 31 | ### CLI autocompletion 32 | 33 | By default, CLI autocompletion is not installed with PM2, we recommend it: 34 | 35 | ```bash 36 | pm2 completion install 37 | ``` 38 | 39 | ### Source map support 40 | 41 | Source map files are autodetected by default if they are present (`app.js.map` for `app.js`). 42 | 43 | What are source map files? If using Babel, Typescript or any other Javascript superset, you may have noticed that stacktraces are not meaningful, errors not pointing to the right line. Source map files can be used to solve this problem. 44 | {: .tip} 45 | 46 | ## Update 47 | 48 | Keep your pm2 up to date with: 49 | 50 | ```bash 51 | npm install pm2 -g && pm2 update 52 | ``` 53 | 54 | `pm2 update` is necessary in order to refresh the PM2 daemon. 55 | {: .tip} 56 | 57 | ## Next Steps 58 | 59 | [Ecosystem File]({{ site.baseurl }}{% link en/runtime/guide/ecosystem-file.md %}) 60 | {: .btn-stylized} 61 | -------------------------------------------------------------------------------- /en/runtime/integration/cloud-providers.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: page 3 | title: Cloud Providers | Integration | PM2 Documentation 4 | menu: starter 5 | lang: en 6 | section: runtime 7 | permalink: "/en/runtime/integration/cloud-providers/" 8 | --- 9 | 10 | # Using PM2 in a Cloud Provider 11 | 12 | You might find yourself in a situation in which you do not have access to the CLI to start your Node.js applications. 13 | 14 | In such a situation, pm2 must be added as a dependency and must be called with the start script. 15 | 16 | ## Prepare your app 17 | 18 | ### Set your ecosystem file 19 | 20 | Generate an `ecosystem.config.js` template with: 21 | 22 | ```bash 23 | pm2 init 24 | ``` 25 | 26 | Modify the ecosystem file to match your needs: 27 | 28 | ```javascript 29 | module.exports = { 30 | apps : [{ 31 | name: "app", 32 | script: "./app.js", 33 | env: { 34 | NODE_ENV: "development", 35 | }, 36 | env_production: { 37 | NODE_ENV: "production", 38 | } 39 | }] 40 | } 41 | ``` 42 | 43 | Learn more about ecosystem file [here]({{ site.baseurl }}{% link en/runtime/guide/ecosystem-file.md %}). 44 | {: .tip} 45 | 46 | ### Add PM2 as a module 47 | 48 | Add pm2 as a dependency to your projet. 49 | 50 | With npm: 51 | 52 | ```bash 53 | npm install pm2 54 | ``` 55 | 56 | With yarn: 57 | 58 | ```bash 59 | yarn add pm2 60 | ``` 61 | 62 | ### Start script in package.json 63 | 64 | In your `package.json`, modify your `start` script like the following: 65 | 66 | ```json 67 | { 68 | "scripts": { 69 | "start": "pm2-runtime start ecosystem.config.js --env production" 70 | } 71 | } 72 | ``` 73 | 74 | ## Deploy your app 75 | 76 | You can now deploy your application in your cloud providers like you would have done for a regular node.js app. 77 | 78 | ## Next Steps 79 | 80 | Complete your configuration with the [Ecosystem File]({{ site.baseurl }}{% link en/runtime/guide/ecosystem-file.md %}). 81 | 82 | Monitor your app on a web dashboard, with [PM2 Plus]({{ site.baseurl }}{% link en/plus/integration/cloud-providers.md %}). 83 | -------------------------------------------------------------------------------- /en/runtime/integration/now.md: -------------------------------------------------------------------------------- 1 | Now.sh is actually not supported 2 | {: .warn} 3 | 4 | # Using PM2 with Now.sh 5 | 6 | This page will guide you step by step through the PM2 integration with Now.sh. 7 | 8 | ## Prepare your app 9 | 10 | ### Set your ecosystem file 11 | 12 | Generate an `ecosystem.config.js` template with: 13 | 14 | ```bash 15 | pm2 init 16 | ``` 17 | 18 | Modify the ecosystem file to match your needs: 19 | 20 | ```javascript 21 | module.exports = { 22 | apps : [{ 23 | name: "app", 24 | script: "./app.js", 25 | env: { 26 | NODE_ENV: "development", 27 | }, 28 | env_production: { 29 | NODE_ENV: "production", 30 | } 31 | }] 32 | } 33 | ``` 34 | 35 | Learn more about ecosystem file [here]({{ site.baseurl }}{% link en/runtime/guide/ecosystem-file.md %}). 36 | {: .tip} 37 | 38 | ### Add PM2 as a module 39 | 40 | Add pm2 as a dependency to your projet. 41 | 42 | With npm: 43 | 44 | ```bash 45 | npm install --save pm2 46 | ``` 47 | 48 | With yarn: 49 | 50 | ```bash 51 | yarn add pm2 52 | ``` 53 | 54 | ### Set your package.json 55 | 56 | In your `package.json`, modify your `start` script like the following: 57 | 58 | ```json 59 | { 60 | "scripts": { 61 | "start": "node ./node_modules/.bin/pm2-runtime start ecosystem.config.js --env production" } 62 | ``` 63 | 64 | ## Deploy with Now.sh 65 | 66 | ### You are ready 67 | 68 | You can now deploy your application on Now.sh like you would have done for a regular node.js app. 69 | 70 | ## Next Steps 71 | 72 | Complete your configuration with the [Ecosystem File]({{ site.baseurl }}{% link en/runtime/guide/ecosystem-file.md %}). 73 | 74 | Monitor your app on a dashboard, with [PM2 Plus]({{ site.baseurl }}{% link en/plus/integration/now.md %}). -------------------------------------------------------------------------------- /en/runtime/integration/transpilers.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: page 3 | title: Transpilers | Integration | PM2 Documentation 4 | menu: starter 5 | lang: en 6 | section: runtime 7 | permalink: "/en/runtime/integration/transpilers/" 8 | --- 9 | 10 | # Using PM2 with transpilers 11 | 12 | This tutorial will show you how to use pm2 with transpilers. 13 | 14 | We highly don't recommend to use this in **production** as it slows down your app. In that case, your app must be bundled i.e. transpiled from the source to get a pre-processed version of your app. 15 | {: .warn} 16 | 17 | ## Typescript 18 | 19 | ```bash 20 | ## Add the new typescript dependency in PM2: 21 | pm2 install typescript 22 | 23 | ## Start app.ts in watch & restart: 24 | pm2 start app.ts --watch 25 | ``` 26 | 27 | ## Babel 28 | 29 | ```bash 30 | ## Install the Babel CLI globally: 31 | npm install -g babel-cli 32 | 33 | ## Start pm2 with the Babel CLI binary in watch mode: 34 | pm2 start --watch --interpreter babel-cli app.js 35 | ``` 36 | 37 | Or, you can create an other file, which requires the transpiler and your app: 38 | ```javascript 39 | // index.js 40 | require('babel-register'); 41 | require('./app.js'); 42 | ``` 43 | Then, run: 44 | ```bash 45 | pm2 start --watch index.js 46 | ``` 47 | 48 | The cluster mode is only available with the second option. 49 | {: .tip} 50 | 51 | ## Coffee-script 52 | 53 | ```bash 54 | ## Install Coffee Script at PM2 level: 55 | pm2 install coffeescript 56 | 57 | ## Start pm2 with coffee binary in watch mode: 58 | pm2 start app.coffee 59 | ``` 60 | 61 | Or, you can install the coffeescript dependency via `npm install coffeescript` and require it in your code: 62 | 63 | ```javascript 64 | // index.js 65 | require('coffee/register'); 66 | require('./app.coffee'); 67 | ``` 68 | 69 | Then, run: 70 | ```bash 71 | pm2 start index.js 72 | ``` 73 | 74 | The cluster mode is only available with the second option. 75 | {: .tip} 76 | -------------------------------------------------------------------------------- /gulpfile.js: -------------------------------------------------------------------------------- 1 | const gulp = require('gulp'); 2 | const sass = require('gulp-sass'); 3 | const gutil = require('gulp-util'); 4 | const child = require('child_process'); 5 | const browserSync = require('browser-sync').create(); 6 | const prefix = require('gulp-autoprefixer'); 7 | 8 | const siteRoot = 'docs/'; 9 | 10 | // Serve static files and auto reload on CSS change 11 | gulp.task('serve', () => { 12 | browserSync.init({ 13 | files: [siteRoot + '/**'], 14 | port: 4010, 15 | proxy: 'localhost:4000' 16 | }); 17 | 18 | gulp.watch('./_sass/**.scss', ['sass']); 19 | }); 20 | 21 | // Start Jekyll 22 | gulp.task('jekyll', () => { 23 | const jekyll = child.spawn('jekyll', [ 24 | 'serve', 25 | '--watch', 26 | '--host=0.0.0.0', 27 | '--incremental', 28 | '--drafts' 29 | ]); 30 | 31 | const jekyllLogger = (buffer) => { 32 | buffer.toString() 33 | .split(/\n/) 34 | .forEach((message) => gutil.log('Jekyll: ' + message)); 35 | }; 36 | 37 | jekyll.stdout.on('data', jekyllLogger); 38 | jekyll.stderr.on('data', jekyllLogger); 39 | }); 40 | 41 | // Transpile scss 42 | gulp.task('sass', function () { 43 | return gulp.src('./_sass/main.scss') 44 | .pipe(prefix()) 45 | .pipe(sass().on('error', sass.logError)) 46 | .pipe(gulp.dest('./docs/css')); 47 | }); 48 | 49 | gulp.task('jekyll-build', (cb) => { 50 | const jekyll = child.spawn('jekyll', [ 51 | 'build' 52 | ]); 53 | 54 | const jekyllLogger = (buffer) => { 55 | buffer.toString() 56 | .split(/\n/) 57 | .forEach((message) => gutil.log('Jekyll: ' + message)); 58 | }; 59 | 60 | jekyll.on('exit', cb) 61 | jekyll.stdout.on('data', jekyllLogger); 62 | jekyll.stderr.on('data', jekyllLogger); 63 | }); 64 | 65 | gulp.task('dist', ['jekyll-build'], function () { 66 | return gulp.src('./_sass/main.scss') 67 | .pipe(prefix()) 68 | .pipe(sass().on('error', sass.logError)) 69 | .pipe(gulp.dest('./docs/css')); 70 | }); 71 | 72 | gulp.task('default', ['sass', 'jekyll', 'serve']); 73 | -------------------------------------------------------------------------------- /img/backgrounds/bg-doc_enterprise.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/keymetrics/doc-pm2/8bf849c8ebf8abeb47c8093beec0299cb9c04d87/img/backgrounds/bg-doc_enterprise.png -------------------------------------------------------------------------------- /img/backgrounds/bg-doc_plus.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/keymetrics/doc-pm2/8bf849c8ebf8abeb47c8093beec0299cb9c04d87/img/backgrounds/bg-doc_plus.png -------------------------------------------------------------------------------- /img/backgrounds/bg-doc_runtime.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/keymetrics/doc-pm2/8bf849c8ebf8abeb47c8093beec0299cb9c04d87/img/backgrounds/bg-doc_runtime.png -------------------------------------------------------------------------------- /img/backgrounds/bg-squares.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/keymetrics/doc-pm2/8bf849c8ebf8abeb47c8093beec0299cb9c04d87/img/backgrounds/bg-squares.png -------------------------------------------------------------------------------- /img/enterprise/alert_global.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/keymetrics/doc-pm2/8bf849c8ebf8abeb47c8093beec0299cb9c04d87/img/enterprise/alert_global.png -------------------------------------------------------------------------------- /img/enterprise/enterprise-black.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/keymetrics/doc-pm2/8bf849c8ebf8abeb47c8093beec0299cb9c04d87/img/enterprise/enterprise-black.png -------------------------------------------------------------------------------- /img/enterprise/frontend-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/keymetrics/doc-pm2/8bf849c8ebf8abeb47c8093beec0299cb9c04d87/img/enterprise/frontend-1.png -------------------------------------------------------------------------------- /img/enterprise/frontend-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/keymetrics/doc-pm2/8bf849c8ebf8abeb47c8093beec0299cb9c04d87/img/enterprise/frontend-2.png -------------------------------------------------------------------------------- /img/enterprise/frontend-3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/keymetrics/doc-pm2/8bf849c8ebf8abeb47c8093beec0299cb9c04d87/img/enterprise/frontend-3.png -------------------------------------------------------------------------------- /img/enterprise/logs.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/keymetrics/doc-pm2/8bf849c8ebf8abeb47c8093beec0299cb9c04d87/img/enterprise/logs.png -------------------------------------------------------------------------------- /img/enterprise/rect-e.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/keymetrics/doc-pm2/8bf849c8ebf8abeb47c8093beec0299cb9c04d87/img/enterprise/rect-e.png -------------------------------------------------------------------------------- /img/logos-pm2/pm2-enterprise_white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/keymetrics/doc-pm2/8bf849c8ebf8abeb47c8093beec0299cb9c04d87/img/logos-pm2/pm2-enterprise_white.png -------------------------------------------------------------------------------- /img/logos-pm2/pm2-plus_white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/keymetrics/doc-pm2/8bf849c8ebf8abeb47c8093beec0299cb9c04d87/img/logos-pm2/pm2-plus_white.png -------------------------------------------------------------------------------- /img/logos-pm2/pm2-runtime_white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/keymetrics/doc-pm2/8bf849c8ebf8abeb47c8093beec0299cb9c04d87/img/logos-pm2/pm2-runtime_white.png -------------------------------------------------------------------------------- /img/logos-pm2/pm2_enterprise.svg: -------------------------------------------------------------------------------- 1 | Fichier 29Enterprise -------------------------------------------------------------------------------- /img/logos-pm2/pm2_monitoring.svg: -------------------------------------------------------------------------------- 1 | Fichier 27Monitoring -------------------------------------------------------------------------------- /img/logos-pm2/pm2_runtime.svg: -------------------------------------------------------------------------------- 1 | Fichier 28runtime -------------------------------------------------------------------------------- /img/logos-pm2/pm2_white.svg: -------------------------------------------------------------------------------- 1 | Fichier 26 -------------------------------------------------------------------------------- /img/plus/2views.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/keymetrics/doc-pm2/8bf849c8ebf8abeb47c8093beec0299cb9c04d87/img/plus/2views.png -------------------------------------------------------------------------------- /img/plus/apps.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/keymetrics/doc-pm2/8bf849c8ebf8abeb47c8093beec0299cb9c04d87/img/plus/apps.png -------------------------------------------------------------------------------- /img/plus/cpu-profiling.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/keymetrics/doc-pm2/8bf849c8ebf8abeb47c8093beec0299cb9c04d87/img/plus/cpu-profiling.png -------------------------------------------------------------------------------- /img/plus/flame-graph.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/keymetrics/doc-pm2/8bf849c8ebf8abeb47c8093beec0299cb9c04d87/img/plus/flame-graph.png -------------------------------------------------------------------------------- /img/plus/issue.old.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/keymetrics/doc-pm2/8bf849c8ebf8abeb47c8093beec0299cb9c04d87/img/plus/issue.old.png -------------------------------------------------------------------------------- /img/plus/issue.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/keymetrics/doc-pm2/8bf849c8ebf8abeb47c8093beec0299cb9c04d87/img/plus/issue.png -------------------------------------------------------------------------------- /img/plus/memory-profiling.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/keymetrics/doc-pm2/8bf849c8ebf8abeb47c8093beec0299cb9c04d87/img/plus/memory-profiling.png -------------------------------------------------------------------------------- /img/plus/modules.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/keymetrics/doc-pm2/8bf849c8ebf8abeb47c8093beec0299cb9c04d87/img/plus/modules.png -------------------------------------------------------------------------------- /img/plus/notifications.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/keymetrics/doc-pm2/8bf849c8ebf8abeb47c8093beec0299cb9c04d87/img/plus/notifications.png -------------------------------------------------------------------------------- /img/plus/personalized.old.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/keymetrics/doc-pm2/8bf849c8ebf8abeb47c8093beec0299cb9c04d87/img/plus/personalized.old.png -------------------------------------------------------------------------------- /img/plus/personalized.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/keymetrics/doc-pm2/8bf849c8ebf8abeb47c8093beec0299cb9c04d87/img/plus/personalized.png -------------------------------------------------------------------------------- /img/plus/plus-black.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/keymetrics/doc-pm2/8bf849c8ebf8abeb47c8093beec0299cb9c04d87/img/plus/plus-black.png -------------------------------------------------------------------------------- /img/plus/profiling.old.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/keymetrics/doc-pm2/8bf849c8ebf8abeb47c8093beec0299cb9c04d87/img/plus/profiling.old.png -------------------------------------------------------------------------------- /img/plus/remote.old.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/keymetrics/doc-pm2/8bf849c8ebf8abeb47c8093beec0299cb9c04d87/img/plus/remote.old.png -------------------------------------------------------------------------------- /img/plus/remote.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/keymetrics/doc-pm2/8bf849c8ebf8abeb47c8093beec0299cb9c04d87/img/plus/remote.png -------------------------------------------------------------------------------- /img/plus/server.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/keymetrics/doc-pm2/8bf849c8ebf8abeb47c8093beec0299cb9c04d87/img/plus/server.png -------------------------------------------------------------------------------- /img/plus/tracing.old.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/keymetrics/doc-pm2/8bf849c8ebf8abeb47c8093beec0299cb9c04d87/img/plus/tracing.old.png -------------------------------------------------------------------------------- /img/plus/tracing.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/keymetrics/doc-pm2/8bf849c8ebf8abeb47c8093beec0299cb9c04d87/img/plus/tracing.png -------------------------------------------------------------------------------- /img/plus/unified.old.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/keymetrics/doc-pm2/8bf849c8ebf8abeb47c8093beec0299cb9c04d87/img/plus/unified.old.png -------------------------------------------------------------------------------- /img/plus/unified.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/keymetrics/doc-pm2/8bf849c8ebf8abeb47c8093beec0299cb9c04d87/img/plus/unified.png -------------------------------------------------------------------------------- /img/pm2-white.svg: -------------------------------------------------------------------------------- 1 | Fichier 26 -------------------------------------------------------------------------------- /img/pm2_docs_og.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/keymetrics/doc-pm2/8bf849c8ebf8abeb47c8093beec0299cb9c04d87/img/pm2_docs_og.png -------------------------------------------------------------------------------- /img/runtime/IAM-add.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/keymetrics/doc-pm2/8bf849c8ebf8abeb47c8093beec0299cb9c04d87/img/runtime/IAM-add.png -------------------------------------------------------------------------------- /img/runtime/IAM-creds.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/keymetrics/doc-pm2/8bf849c8ebf8abeb47c8093beec0299cb9c04d87/img/runtime/IAM-creds.png -------------------------------------------------------------------------------- /img/runtime/IAM-prog.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/keymetrics/doc-pm2/8bf849c8ebf8abeb47c8093beec0299cb9c04d87/img/runtime/IAM-prog.png -------------------------------------------------------------------------------- /img/runtime/IAM-strat.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/keymetrics/doc-pm2/8bf849c8ebf8abeb47c8093beec0299cb9c04d87/img/runtime/IAM-strat.png -------------------------------------------------------------------------------- /img/runtime/autocomplete.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/keymetrics/doc-pm2/8bf849c8ebf8abeb47c8093beec0299cb9c04d87/img/runtime/autocomplete.png -------------------------------------------------------------------------------- /img/runtime/cluster-mode.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/keymetrics/doc-pm2/8bf849c8ebf8abeb47c8093beec0299cb9c04d87/img/runtime/cluster-mode.png -------------------------------------------------------------------------------- /img/runtime/help.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/keymetrics/doc-pm2/8bf849c8ebf8abeb47c8093beec0299cb9c04d87/img/runtime/help.png -------------------------------------------------------------------------------- /img/runtime/monit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/keymetrics/doc-pm2/8bf849c8ebf8abeb47c8093beec0299cb9c04d87/img/runtime/monit.png -------------------------------------------------------------------------------- /img/runtime/pm2ls.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/keymetrics/doc-pm2/8bf849c8ebf8abeb47c8093beec0299cb9c04d87/img/runtime/pm2ls.png -------------------------------------------------------------------------------- /img/runtime/rect-r.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/keymetrics/doc-pm2/8bf849c8ebf8abeb47c8093beec0299cb9c04d87/img/runtime/rect-r.png -------------------------------------------------------------------------------- /img/runtime/runtime-black.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/keymetrics/doc-pm2/8bf849c8ebf8abeb47c8093beec0299cb9c04d87/img/runtime/runtime-black.png -------------------------------------------------------------------------------- /img/sidebar2/pm2_enterprise.svg: -------------------------------------------------------------------------------- 1 | Fichier 29Enterprise -------------------------------------------------------------------------------- /img/sidebar2/pm2_monitoring.svg: -------------------------------------------------------------------------------- 1 | Fichier 27Monitoring -------------------------------------------------------------------------------- /img/sidebar2/pm2_runtime.svg: -------------------------------------------------------------------------------- 1 | Fichier 28runtime -------------------------------------------------------------------------------- /img/sidebar2/pm2_white.svg: -------------------------------------------------------------------------------- 1 | Fichier 26 -------------------------------------------------------------------------------- /index.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: home 3 | title: PM2 Documentation 4 | menu: starter 5 | lang: en 6 | section: 7 | --- 8 | -------------------------------------------------------------------------------- /js/main.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | 3 | $(document).ready(function(event) { 4 | setAnchors(); 5 | setGitalk(); 6 | logoTogglesSidebarOnMobile(); 7 | }); 8 | 9 | function setAnchors() { 10 | var anchorForId = function (id) { 11 | var anchor = document.createElement("a"); 12 | anchor.className = "header-link"; 13 | anchor.href = "#" + id; 14 | anchor.innerHTML = "link"; 15 | return anchor; 16 | }; 17 | 18 | var linkifyAnchors = function (level, containingElement) { 19 | var headers = containingElement.getElementsByTagName("h" + level); 20 | for (var h = 0; h < headers.length; h++) { 21 | var header = headers[h]; 22 | 23 | $(header).attr('onClick','location.hash="' + header.id + '"'); 24 | if (typeof header.id !== "undefined" && header.id !== "") { 25 | header.appendChild(anchorForId(header.id)); 26 | } 27 | } 28 | }; 29 | 30 | document.onreadystatechange = function () { 31 | if (this.readyState === "complete") { 32 | var contentBlock = document.getElementsByClassName("content")[0]; 33 | if (!contentBlock) { 34 | return; 35 | } 36 | for (var level = 2; level <= 6; level++) { 37 | linkifyAnchors(level, contentBlock); 38 | } 39 | } 40 | }; 41 | } 42 | 43 | function setGitalk() { 44 | var gitalk = new Gitalk({ 45 | clientID: '918c405abac62eacf227', 46 | clientSecret: '7c102fd9965dbe94ce2fb6006ccadcac8f2b9d44', 47 | repo: 'doc-pm2', 48 | owner: 'keymetrics', 49 | admin: ['robin-monnier', 'vmarchaud', 'Unitech'], 50 | language: document.documentElement.lang === 'zh' ? 'zh-CN' : 'en', 51 | id: md5(window.location.pathname), 52 | // facebook-like distraction free mode 53 | distractionFreeMode: false 54 | }) 55 | 56 | $(document).ready(function() { 57 | if (document.querySelector('#gitalk')) { 58 | gitalk.render('gitalk'); 59 | } 60 | }); 61 | } 62 | 63 | function logoTogglesSidebarOnMobile() { 64 | $('.burger-header').click(function() { 65 | $('.sidebar').toggleClass('open') 66 | }) 67 | } 68 | })(); 69 | -------------------------------------------------------------------------------- /js/prism-clipboard.js: -------------------------------------------------------------------------------- 1 | // Mostly taken from : https://webdesign.tutsplus.com/tutorials/copy-to-clipboard-made-easy-with-clipboardjs--cms-25086 2 | document.addEventListener('DOMContentLoaded', function() { 3 | 4 | // Get the elements. 5 | // - the 'pre' element. 6 | // - the 'div' with the 'paste-content' id. 7 | 8 | var pre = document.getElementsByTagName('pre'); 9 | var pasteContent = document.getElementById('paste-content'); 10 | 11 | // Add a copy button in the 'pre' element. 12 | // which only has the className of 'language-'. 13 | 14 | 15 | for (var i = 2; i < pre.length; i++) { // var i = 1, because the first pre element were not code snippet 16 | var isLanguage = pre[i].children[0].className.indexOf('language-'); 17 | 18 | if ( isLanguage === 1 ) { 19 | var button = document.createElement('button'); 20 | button.className = 'docsify-copy-code-button'; 21 | button.textContent = 'Copy'; 22 | 23 | pre[i].appendChild(button); 24 | 25 | var codeLang = pre[i].className.match(/[^-]+$/)[0]; //find class in pre element 26 | pre[i].setAttribute("data-lang", codeLang); 27 | 28 | } 29 | }; 30 | 31 | // Run Clipboard 32 | 33 | var copyCode = new ClipboardJS('.docsify-copy-code-button', { 34 | target: function(trigger) { 35 | return trigger.previousElementSibling; 36 | } 37 | }); 38 | 39 | // On success: 40 | // - Change the "Copy" text to "Copied". 41 | // - Swap it to "Copy" in 2s. 42 | 43 | copyCode.on('success', function(event) { 44 | event.clearSelection(); 45 | event.trigger.textContent = 'Copied'; 46 | window.setTimeout(function() { 47 | event.trigger.textContent = 'Copy'; 48 | }, 2000); 49 | }); 50 | 51 | // On error (Safari): 52 | // - Change the "Press Ctrl+C to copy" 53 | // - Swap it to "Copy" in 2s. 54 | 55 | copyCode.on('error', function(event) { 56 | event.trigger.textContent = 'Press "Ctrl + C" to copy'; 57 | window.setTimeout(function() { 58 | event.trigger.textContent = 'Copy'; 59 | }, 5000); 60 | }); 61 | 62 | 63 | }); 64 | -------------------------------------------------------------------------------- /misc/cli-parser.js: -------------------------------------------------------------------------------- 1 | const fs = require('fs') 2 | 3 | // const { exec } = require('child_process') 4 | // const pm2Help = exec('pm2', ['-h']) 5 | 6 | // let stream = fs.createWriteStream('./pm2Help') 7 | 8 | // pm2Help.stdout.on('data', (data) => { 9 | // stream.write(data) 10 | // console.log(data) 11 | // }) 12 | 13 | // pm2Help.stderr.on('data', (data) => { 14 | // console.log(`stderr: ${data}`) 15 | // }) 16 | 17 | // pm2Help.on('close', (code) => { 18 | // console.log(`child process exited with code ${code}`) 19 | // stream.end() 20 | // }) 21 | 22 | const escapeSpecialChar = (str) => { 23 | if (typeof str !== typeof '') { return str } 24 | return str.replace(/\|/g, '|') 25 | .replace(/\/g, '>') 27 | } 28 | 29 | const schema = fs.readFileSync('./pm2Help').toString() 30 | // console.log(schema) 31 | const tab = schema.split('\n') 32 | stream = fs.createWriteStream('./cli.md') 33 | 34 | stream.write('# CLI reference') 35 | stream.write('\n\n### pm2 Flags\n\n') 36 | stream.write('Flag name|Description\n') 37 | stream.write('---|---\n') 38 | 39 | let i = 0; 40 | while (!tab[i].match(/Options/)) { 41 | i++ 42 | } 43 | i = i + 2 44 | while (tab[i].length) { 45 | const flag = tab[i].split(/ {2,}/).filter((entry) => { return entry.trim() != '' }) 46 | const flagName = escapeSpecialChar(flag[0]) 47 | const flagDescription = escapeSpecialChar(flag[1]) 48 | stream.write(`${flagName}|${flagDescription}\n`) 49 | i++ 50 | } 51 | while (!tab[i].match(/Commands/)) { 52 | i++ 53 | } 54 | i = i + 2 55 | 56 | stream.write('\n\n### pm2 Commands\n\n') 57 | stream.write('Command name|Description\n') 58 | stream.write('---|---\n') 59 | while (i < tab.length) { 60 | // console.log(tab[i]) 61 | const flag = tab[i].split(/ {2,}/).filter((entry) => { return entry.trim() != '' }) 62 | const flagName = escapeSpecialChar(flag[0]) 63 | const flagDescription = escapeSpecialChar(flag[1]) 64 | stream.write(`${flagName}|${flagDescription}\n`) 65 | i++ 66 | } 67 | 68 | stream.end() -------------------------------------------------------------------------------- /misc/ecosystem-parser.js: -------------------------------------------------------------------------------- 1 | const axios = require('axios') 2 | const fs = require('fs') 3 | 4 | // const schema = axios.get('https://raw.githubusercontent.com/Unitech/pm2/master/lib/API/schema.json') 5 | // .then(res => { return res.data }) 6 | const schema = JSON.parse(fs.readFileSync('./schema.json')) 7 | 8 | const escapeVerticalBar = (str) => { 9 | if (typeof str !== typeof '') { return str } 10 | return str.replace(/\|/g, '|') 11 | } 12 | 13 | const stream = fs.createWriteStream('./ecosystem.md') 14 | 15 | stream.write('# Ecosystem file reference\n\n') 16 | stream.write('Entry name|Description|Type|Default\n') 17 | stream.write('---|---|---|---\n') 18 | 19 | for (let key of Object.keys(schema)) { 20 | const description = escapeVerticalBar(schema[key].description) 21 | const type = escapeVerticalBar(schema[key].type) 22 | const defaultValue = escapeVerticalBar(schema[key].default) 23 | 24 | stream.write(`${key}|${description || ''}|${type || ''}|${defaultValue || ''}\n`) 25 | } 26 | stream.end() 27 | -------------------------------------------------------------------------------- /misc/metrics.js: -------------------------------------------------------------------------------- 1 | const metrics = { 2 | { 3 | id: 1, 4 | displayName: "CPU Usage", 5 | unit: "%", 6 | range: "0 - 100" 7 | shortDesc: "The CPU usage is the amount of time the CPU is busy. A CPU only can handle one operation at a time and so is either busy or idle.", 8 | longDesc: "", 9 | externalDoc: "" 10 | }, 11 | { 12 | id: 2, 13 | displayName: "Memory Usage", 14 | unit: "Megabytes (MB)", 15 | range: "0 - total memory of the server", 16 | shortDesc: "The memory usage is the total amount of memory used by the application.", 17 | longDesc: "", 18 | externalDoc: "" 19 | }, 20 | { 21 | id: 3, 22 | displayName: "Issues", 23 | shortDesc: "The number of new issues recorded in the app.", 24 | longDesc: "", 25 | externalDoc: "" 26 | }, 27 | { 28 | id: 4, 29 | displayName: "Number of restart", 30 | shortDesc: "The number of restart of your application since added to the PM2 process list.", 31 | longDesc: "The number of restart of your application since added to the PM2 process list. PM2 automatically restarts your application whenever needed, for example after an uncaught exception has happened.", 32 | externalDoc: "" 33 | }, 34 | { 35 | id: 5, 36 | displayName: "Number of processes", 37 | shortDesc: "The number of cluster on which your app has been spread on the server.", 38 | longDesc: "The number of cluster on which your app has been spread on the server. Only PM2 clusters appear.", 39 | externalDoc: "" 40 | }, 41 | { 42 | id: 6, 43 | displayName: "HTTP requests per minute", 44 | unit: "Requests / minute (rpm)", 45 | shortDesc: "The number of requests the app is receiving per minute.", 46 | longDesc: "", 47 | externalDoc: "" 48 | }, 49 | { 50 | id: 7, 51 | displayName: "Loop delay", 52 | unit: "Milliseconds (ms)", 53 | shortDesc: "How long it takes for Node.js to complete a full event loop.", 54 | longDesc: "", 55 | externalDoc: "" 56 | }, 57 | { 58 | id: 8, 59 | displayName: "Active handles", 60 | shortDesc: "Handles represent long-lived objects capable of performing certain operations while active (a listening server for example).", 61 | longDesc: "Handles represent long-lived objects capable of performing certain operations while active. Some examples: - A prepare handle gets its callback called once every loop iteration when active. - A TCP server handle that gets its connection callback called every time there is a new connection.", 62 | externalDoc: "" 63 | }, 64 | { 65 | id: 9, 66 | displayName: "Active requests", 67 | shortDesc: "Requests represent short-lived operations (write requests used to write data on a handle for example).", 68 | longDesc: "Requests represent short-lived operations. These operations can be performed over a handle: write requests are used to write data on a handle; or standalone: getaddrinfo requests don’t need a handle they run directly on the loop.", 69 | externalDoc: "" 70 | }, 71 | } -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "doc-pm2", 3 | "version": "1.0.0", 4 | "description": "1. sudo apt install clang make ruby-dev libffi-dev\r 2. `bundle install`\r 3. `bundle exec jekyll serve`", 5 | "main": "mapping-plus.js", 6 | "directories": { 7 | "doc": "docs" 8 | }, 9 | "scripts": { 10 | "test": "echo \"Error: no test specified\" && exit 1", 11 | "dev": "docker run -p 80:4000 -v $(pwd):/site bretfisher/jekyll-serve" 12 | }, 13 | "repository": { 14 | "type": "git", 15 | "url": "git+https://github.com/keymetrics/doc-pm2.git" 16 | }, 17 | "author": "", 18 | "license": "ISC", 19 | "bugs": { 20 | "url": "https://github.com/keymetrics/doc-pm2/issues" 21 | }, 22 | "homepage": "https://github.com/keymetrics/doc-pm2#readme", 23 | "dependencies": { 24 | "gulp-autoprefixer": "^5.0.0", 25 | "gulp-sass": "^4.0.1", 26 | "ins": "0.0.0" 27 | }, 28 | "devDependencies": { 29 | "browser-sync": "^2.24.4", 30 | "gulp": "^3.9.1", 31 | "gulp-util": "^3.0.8", 32 | "stylelint-config-standard": "^18.2.0" 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /static/hamburger-enterprise.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/keymetrics/doc-pm2/8bf849c8ebf8abeb47c8093beec0299cb9c04d87/static/hamburger-enterprise.png -------------------------------------------------------------------------------- /static/hamburger-monitoring.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/keymetrics/doc-pm2/8bf849c8ebf8abeb47c8093beec0299cb9c04d87/static/hamburger-monitoring.png -------------------------------------------------------------------------------- /static/hamburger-runtime.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/keymetrics/doc-pm2/8bf849c8ebf8abeb47c8093beec0299cb9c04d87/static/hamburger-runtime.png -------------------------------------------------------------------------------- /static/pm-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/keymetrics/doc-pm2/8bf849c8ebf8abeb47c8093beec0299cb9c04d87/static/pm-2.png -------------------------------------------------------------------------------- /static/pm-2@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/keymetrics/doc-pm2/8bf849c8ebf8abeb47c8093beec0299cb9c04d87/static/pm-2@2x.png -------------------------------------------------------------------------------- /static/pm-2@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/keymetrics/doc-pm2/8bf849c8ebf8abeb47c8093beec0299cb9c04d87/static/pm-2@3x.png -------------------------------------------------------------------------------- /static/pm2-logo-e.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/keymetrics/doc-pm2/8bf849c8ebf8abeb47c8093beec0299cb9c04d87/static/pm2-logo-e.png -------------------------------------------------------------------------------- /static/pm2-logo-m.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/keymetrics/doc-pm2/8bf849c8ebf8abeb47c8093beec0299cb9c04d87/static/pm2-logo-m.png -------------------------------------------------------------------------------- /static/pm2-logo-r.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/keymetrics/doc-pm2/8bf849c8ebf8abeb47c8093beec0299cb9c04d87/static/pm2-logo-r.png -------------------------------------------------------------------------------- /zh/enterprise/overview.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: page 3 | title: Quick Start with PM2 4 | menu: starter 5 | lang: zh 6 | section: enterprise 7 | --- 8 | 9 |

10 | pm2 logo 11 |

12 |

13 | P(rocess) M(anager) 2
14 | Enterprise Edition 15 |

-------------------------------------------------------------------------------- /zh/plus/best-practices/README.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: page 3 | title: 监控最佳实践 | PM2 Plus教程 4 | title-en: Best Practices | PM2 Plus Documentation 5 | menu: starter 6 | lang: zh 7 | section: plus 8 | permalink: "/zh/plus/best-practices/" 9 | --- 10 | 11 | # 监控最佳实践 12 | 13 | 本节收集了有关最佳实践的内容,以便从一开始就可以扩展您的应用。 14 | 15 | - [CPU分析]({{ site.baseurl }}{% link zh/plus/best-practices/cpu-profiling.md %}) 16 | - [内存分析]({{ site.baseurl }}{% link zh/plus/best-practices/memory-profiling.md %}) 17 | - [事务跟踪]({{ site.baseurl }}{% link zh/plus/best-practices/transaction-tracing.md %}) 18 | -------------------------------------------------------------------------------- /zh/plus/best-practices/cpu-profiling.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: page 3 | title: CPU分析 | 监控最佳实践 | PM2 Plus教程 4 | title-en: CPU Profiling | Best Practices | PM2 Plus Documentation 5 | menu: starter 6 | lang: zh 7 | section: runtime 8 | section: plus 9 | --- 10 | 11 | # CPU分析 12 | 13 | PM2配备了可随时使用的CPU分析工具。 网络仪表板允许您在同一处分析所有服务器。 我们的可视化工具可帮助您可视化并解释分析您的结果,从而提高应用的性能。 分析文件也可以在Chrome开发工具中下载并检测。 14 | 15 | ## 为什么选择CPU分析? 16 | 17 | CPU分析是诊断服务器CPU使用方式的工具。 CPU是每台计算机的核心部件,作为负责解释和执行几乎所有命令的组件,有时甚至可以被称为计算机的“大脑”。 18 | 19 | Web服务器执行后端代码越多,需要的CPU功率就越多。 在静态内容Web服务器中,由于只有很少的操作在后端完成,因此计算量不大。 另一方面,在Web API的情况下,只有后端代码:CPU是实现高性能的核心。 20 | 21 | 除了获得尽可能高的CPU功率之外,只有通过优化代码才能提高API性能。 CPU分析提供了探寻在代码中如何跨功能使用CPU的功能。 一旦发现瓶颈,您就可以采取行动了。 22 | 23 | ## 数据采集 24 | 25 | CPU分析如何工作? 26 | 27 | 探查器需要记录所有调用的函数以及CPU花费多长时间。 28 | 29 | 第一种方法是所谓的“仪器”。 该方法通过插入一段代码来计算调用次数并记录函数的执行时间。 这种方法的缺点是累赘。 它会影响很多代码的执行,即便它是精确的,它在活动的Web服务器内容上也是有问题的。 30 | 31 | 另一种方法是“抽样”。 在这种方法中,分析器以特定间隔中断代码执行并且每次都记录堆栈跟踪。 并非每个调用都被记录下来,但经过足够的时间后,得到的结论仍具有相关性。 这种方法最大的好处是它几乎不会影响代码执行,且可以在生产环境中使用。 32 | 33 | 一些分析器使用混合方法。 他们只用仪器代码来计算调用次数(一种廉价操作)并使用采样来衡量功能执行时间。 34 | 35 | PM2分析器使用抽样方法。 36 | 37 | ## 数据表现 38 | 39 | 收集后,需要组织这样大量的数据,以便进行分析并提出问题。 以下是处理CPU分析结果的三种常用方法。 40 | 41 | ### 自上而下视图 42 | 43 | 自上而下视图显示方法调用的列表,展开方法节点显示其被调用者。 44 | 45 | “自上而下”选项卡提供以下信息以帮助描述在每个方法调用上花费的CPU时间(时间也表示为所选时间范围内线程总时间的百分比): 46 | 47 | Self:方法调用执行自己的代码的时间,而不是它的被调用者。 48 | Children:方法调用花费在执行被调用者上的时间,而不是自己的代码。 49 | 总计:该方法的Self和Children时间的总和。 这表示应用程序执行方法调用所用的总时间。 50 | 51 | ### 自下而上视图 52 | 53 | 自下而上视图显示方法调用的列表,展开方法的节点显示其调用者。 54 | 55 | 自下而上视图对于那些消耗最多(或最少)CPU时间的方法排序很有用。 您可以检查每个节点,以确定哪些调用者花费大量CPU时间调用这些方法。 与自顶向下的树相比,底层树中每个方法的计时信息参照每个树顶部的方法(顶层节点)。 CPU时间也表示为该录制过程中线程总时间的百分比。 下表帮助解释了如何解释顶层节点及其调用方法(子节点)的时间信息。 56 | 57 | ### 火焰图 58 | 59 | 火焰图中的每个框代表堆叠中的一个功能。 60 | 61 | y轴显示堆栈深度。 机顶盒显示CPU上的功能。 在那之下的一切都是ancestry。 函数下面的函数是它的主类,就像前面显示的堆栈跟踪一样。 62 | X轴横跨样本总数。 它并不像大多数图表那样显示从左到右的时间流逝。 从左到右排序没有意义(它是按字母顺序的)。 63 | 框的宽度显示它在CPU上的总时间或CPU上的ancestry的一部分(基于样本数)。 使用宽框的功能可能会比使用窄框的功能消耗更多的CPU,或可能会更频繁地调用它们。 调用计数未显示(或通过采样已知)。 64 | 如果多个线程正在运行并同时采样,则样本计数可能会超过已用时间。 65 | 颜色不重要,通常随机挑选为暖色调(支持其他有意义的调色板)。 这种可视化被称为“火焰图”,因为它最初用于显示CPU上的热点,并且看起来像火焰。 它也是交互式的:将鼠标悬停在SVG上以显示细节,然后单击以放大。 66 | 67 | ## 如何解释结果? 68 | 69 | 让我们深入了解如何解释CPU分析以加快您的代码。 通过与源代码分析配对可以检测到以下情况: 70 | 71 | - 个别繁重的功能(例如排序功能); 72 | - 过度使用库函数(例如存储器复制函数); 73 | - 反复出现函数调用序列。 74 | 75 | 为了找到单独的重型功能,平面视图就足够了。 按自重和降序排序,这些功能将泡到顶端。 特别是如果他们的总重量接近自重(这意味着他们自完成所有工作),他们是优化的理想方法。 此方法适用于递归和非递归函数。 76 | 77 | 如果某个热门功能本身无法优化(例如,这是一个库函数),则自下而上的视图有助于查看其调用者。 获得最多权重的调用者(即最频繁调用函数的调用者),并查看源代码中为什么会过度使用该函数。 通常看起来,函数调用的结果可以被缓存,或可能有一种更有效的方法来做同样的事情,根本不需要调用函数。 78 | 79 | 按照总重量降序排列平视图,用自重排序次级视图也可以揭示由不适当导致重处理的功能。 考虑一个例子:假设我们看到一个函数`top5',它有很大的总重量,但是自重很小。 现在我们从自顶向下的角度来看待它的被调用者,并且看到`top5的时间大部分被占用于调用 `qsort’。查看`top5'源代码,我们发现这个调用是多余的,因为查找前5个数组项可以使用单个线性扫描来完成,而无需对数组进行排序。 80 | 81 | 调用图视图实际上可以用于所有这些情况,特别是如果可以调整它以基于其权重突出显示节点和边缘。 正如我所说,呼叫图的唯一问题在于它可能很大,因此需要一个好的可扩展方法来查看它。 82 | 83 | 但当我们想找到一个重复出现的函数调用序列时,一个调用图是真实可行的。 由于每个程序的功能只有一个相应的节点(不同于树视图),并且边具有权重,因此检测昂贵的序列相对容易。 在找到它们并查看函数的代码后,似乎通过函数计算的数据通常仅被部分使用,或甚至被调用者丢弃(当程序是从大型的可重用'通用'函数构建时发生的)。 编写一个不需要执行不必要计算的函数的特别版本可以大大加快程序的速度。 -------------------------------------------------------------------------------- /zh/plus/best-practices/memory-profiling.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: page 3 | title: 内存分析 | 监控最佳实践 | PM2 Plus教程 4 | title-en: Memory Profiling | Best Practices | PM2 Plus Documentation 5 | menu: starter 6 | lang: zh 7 | section: runtime 8 | section: plus 9 | --- 10 | 11 | # 内存分析 -------------------------------------------------------------------------------- /zh/plus/best-practices/metrics-glossary.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: page 3 | title: Metrics Glossary | Best Practices | PM2 Plus Documentation 4 | title-en: Metrics Glossary | Best Practices | PM2 Plus Documentation 5 | menu: starter 6 | lang: zh 7 | section: plus 8 | permalink: "/zh/en/plus/best-practices/metrics-glossary" 9 | --- 10 | 11 | # Metrics Glossary 12 | 13 | CPU Usage 14 | 15 | Unit: % 16 | Range of values: 0 - 100 17 | 18 | The CPU usage is the amount of time the CPU is busy (computed every 25 ms, for the last 25 ms). 19 | 20 | Memory Usage 21 | 22 | Unit: Megabytes (MB) 23 | Range of values: 0 - total memory of the server 24 | 25 | The memory usage is the total amount of memory used by the application. 26 | 27 | Issues 28 | 29 | The number of issues recorded and not yet set as fixed in the issue dashboard. 30 | 31 | Number of restarts 32 | 33 | The number of restarts of your application since added in your PM2 process list. PM2 automatically restarts your application whenever needed, for example after an uncaught exception has happened. 34 | 35 | Number of processes 36 | 37 | The number of cluster on which your app has been spread on the server. Only PM2 cluster appears. 38 | 39 | HTTP Requests per Minutes 40 | 41 | Unit: Number of requests / minutes 42 | 43 | Loop Delay 44 | 45 | Unit: milliseconds (ms) 46 | Range: 0 - less than 100ms 47 | 48 | The time the Node.js event loop takes to complete a loop. 49 | 50 | 51 | Active Handles 52 | 53 | Handles represent long-lived objects capable of performing certain operations while active. Some examples: 54 | 55 | - A prepare handle gets its callback called once every loop iteration when active. 56 | - A TCP server handle that gets its connection callback called every time there is a new connection. 57 | 58 | Active Requests 59 | 60 | Requests represent (typically) short-lived operations. These operations can be performed over a handle: write requests are used to write data on a handle; or standalone: getaddrinfo requests don’t need a handle they run directly on the loop. 61 | 62 | Node.js Memory 63 | 64 | New space used size 65 | 66 | Old space used size 67 | 68 | Map space used size 69 | 70 | Code space used size 71 | 72 | Large object space used suze 73 | 74 | Heap size 75 | 76 | Heap size executable 77 | 78 | Used heap size 79 | 80 | Heap size limit 81 | 82 | Garbage Collector 83 | 84 | GC heap size 85 | 86 | GC executable heap size 87 | 88 | GC used heap size 89 | 90 | GC type 91 | 92 | Gc Pause -------------------------------------------------------------------------------- /zh/plus/best-practices/transaction-tracing.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: page 3 | title: 事务跟踪 | 监控最佳实践 | PM2 Plus教程 4 | title-en: Transaction Tracing | Best Practices | PM2 Plus Documentation 5 | menu: starter 6 | lang: zh 7 | section: plus 8 | --- 9 | 10 | # 事务跟踪 -------------------------------------------------------------------------------- /zh/plus/guide/README.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: page 3 | title: 指南 | PM2 Plus教程 4 | title-en: Guide | PM2 Plus Documentation 5 | menu: starter 6 | lang: zh 7 | section: plus 8 | permalink: "/zh/plus/guide/" 9 | --- 10 | 11 | # 指南 12 | 13 | 本指南将在几分钟内使您的node.js应用通过PM2 Plus进行监控. 14 | 15 | ### 术语 16 | 17 | 我们来解释一下在本指南中使用的一些术语: 18 | 19 | **bucket** 是我们用来收集多个服务器的实体。 一个bucket通常用于从一个项目中收集多个服务器. 20 | 21 | **server** 是PM2 Plus从其接收来自一个或多个进程信息的实体. 22 | 23 | **process** 是进程列表 (`pm2 ls`)的实体。 24 | 25 | [开始吧]({{ site.baseurl }}{% link zh/plus/guide/installation.md %}) 26 | {: .btn-stylized} 27 | -------------------------------------------------------------------------------- /zh/plus/guide/configuration.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: page 3 | title: 配置 | 指南 | PM2 Plus教程 4 | title-en: Configuration | Guide | PM2 Plus Documentation 5 | menu: starter 6 | lang: zh 7 | section: plus 8 | --- 9 | 10 | # 配置 11 | 12 | 您的仪表板带有大量指标,无需配置。 13 | 14 | 但是,可以使用 **PMX library**完成进一步配置。 这是一个轻量级的库,用于您的服务器和仪表板之间的高级交互。 15 | 16 | - **公开自定义指标**以丰富您的仪表板 17 | - **公开自定义操作**可从任何地方远程触发 18 | - **发送事件**来跟踪任何你想的 19 | - **优化异常检测**以便检测及捕捉 20 | 21 | ## PMX安装 22 | 23 | 使用npm: 24 | 25 | ```bash 26 | npm install @pm2/io --save 27 | ``` 28 | 29 | 使用yarn: 30 | 31 | ```bash 32 | yarn add @pm2/io 33 | ``` 34 | 35 | ## PMX初始化 36 | 37 | 在任何其他`require`之前加载并初始化您应用顶层的io。 38 | 39 | ```javascript 40 | const io = require('@pm2/io').init({ 41 | // Enable the exception reporting, default true 42 | errors: true, 43 | // Enable the transaction tracing, default false 44 | transactions: false, 45 | // Enable the profiling, default true 46 | profiling: true, 47 | }) 48 | ``` 49 | 50 | 请参阅[参考]({{ site.baseurl }}{% link zh/plus/reference/pmx.md %})中的其他初始化选项。 51 | {: .tip} 52 | 53 | ## 显示自定义指标 54 | 55 | io为您提供一个探针构造函数,使您能够将变量值显示在仪表板上。 56 | 57 | 例子: 58 | 59 | ```javascript 60 | const probe = require('@pm2/io').probe(); 61 | 62 | let counter = 0; 63 | 64 | const metric = probe.metric({ 65 | name: 'Online users', 66 | type: 'custom/users', // unique id that identify the metric 67 | unit: null, // value of the metric that will be displayed on the dashboard 68 | agg_type: 'avg', // This param is optionnal, it can be `sum`, `max`, `min`, `avg` (default) or `none`. It will impact the way the probe data are aggregated. Use `none` if this is irrelevant (eg: constant or string value). 69 | value: () => { 70 | return counter; 71 | } 72 | }) 73 | 74 | const metric = probe.metric({ 75 | name : 'Realtime user', 76 | value : () => { 77 | return Object.keys(users).length; 78 | } 79 | }) 80 | ``` 81 | 82 | 请注意,自定义度量标准值每秒发送一次,发生于您所提供的函数调用。 83 | 84 | 在[PMX参考]({{ site.baseurl }}{% link zh/plus/reference/pmx.md %})中阅读更多关于显示自定义指标的信息。 85 | {: .tip} 86 | 87 | ## 实现远程操作 88 | 89 | 您可以直接从仪表板远程触发功能。 从代码中实现后,可以在特定部分的主仪表板页面中找到操作按钮。 90 | 91 | 操作命令将一个函数作为参数,一旦作业完成后需要调用该参数。 92 | 93 | 例子: 94 | 95 | ```javascript 96 | const io = require('@pm2/io'); 97 | 98 | io.action('db:clean', function(reply) { 99 | clean.db(() => { 100 | /** 101 | * reply() must be called at the end of the action 102 | */ 103 | reply({success : true}); 104 | }); 105 | }); 106 | ``` 107 | 108 | 在 [PMX参考]({{ site.baseurl }}{% link zh/plus/reference/pmx.md %})中详细了解如何实现远程操作。 109 | {: .tip} 110 | 111 | ## 触发事件 112 | 113 | 触发事件以获取历史记录或统计数据。 114 | 115 | ```javascript 116 | const io = require('@pm2/io') 117 | 118 | io.emit('user:register', { 119 | user: 'Alex registered', 120 | email: 'thorustor@gmail.com' 121 | }) 122 | ``` 123 | 124 | 在 [PMX 参考]({{ site.baseurl }}{% link zh/plus/reference/pmx.md %})中详细了解触发事件。 125 | {: .tip} 126 | 127 | ## 下一步 128 | 129 | [通知]({{ site.baseurl }}{% link zh/plus/guide/notifications.md %}) 130 | {: .btn-stylized} 131 | 132 | ## 疑问? 133 | 134 | 我们一直乐于帮您解决可能遇到的问题。搜索我们的文档或查看常见问题的答案。您也可以在我们的社区论坛发布问题或评论。您也可以查看我们在github中的帮助部分 https://github.com/keymetrics/keymetrics-support 135 | -------------------------------------------------------------------------------- /zh/plus/guide/installation.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: page 3 | title: 安装 | 指南 | PM2 Plus教程 4 | title-en: Installation | Guide | PM2 Plus Documentation 5 | menu: starter 6 | lang: zh 7 | section: plus 8 | --- 9 | 10 | # 安装 11 | 12 | 我们假设您的应用已开始使用PM2 runtime。 如果没有,请参考 [快速入门]({{ site.baseurl }}{% link en/runtime/quick-start.md %}) 教程。 13 | 14 | ## 创建一个帐户 15 | 16 | 在 [此处](https://id.keymetrics.io/api/oauth/register)注册。 17 | 18 | ## 将您的服务器连接到仪表板 19 | 20 | 将您的服务器连接到仪表板,并开始收集指标: 21 | 22 | ```bash 23 | pm2 link 24 | ``` 25 | 26 | 或者,如果您无权访问CLI,请添加使用公钥和私钥设置的 `PM2_PUBLIC_KEY`和 `PM2_SECRET_KEY`环境变量。 27 | 28 | 您可以在仪表板的右上方找到密钥和公钥 29 | {: .tip} 30 | 31 | ### 如果您在公司proxy/防火墙的保护中 32 | 33 | 为了使Keymetrics正常工作,请确保这些端口是开放的: 34 | - 80 (TCP outbound) 35 | - 443 (HTTPS outbound) 36 | - 43554 (TCP outbound) 37 | 38 | 如果您还需要将IP地址列入白名单,请允许下列地址: 39 | 163.172.76.240, 62.210.94.153, 195.154.156.78, 62.210.100.99, 62.210.102.213, 62.4.21.42, 62.4.21.98 and 163.172.20.79. 40 | 41 | ## 安装CPU/内存分析 42 | 43 | ### g++ 44 | 45 | 您必须安装 `g++`: 46 | 47 | 在Linux上,输入 `sudo apt-get install build-essential`。 48 | 49 | 在Mac上,在终端中输入 `g++`,然后按照说明操作。 50 | 51 | ### CPU/内存分析器 52 | 53 | 使用PM2安装程序: 54 | 55 | ```bash 56 | pm2 install profiler 57 | ``` 58 | 59 | 然后重载您的应用以启用分析器: 60 | 61 | ```bash 62 | pm2 reload all 63 | ``` 64 | 65 | ## 您已完成 66 | 67 | 返回仪表板,您现在已可以访问您应用的实时指标。 68 | 69 | ![仪表板视图]({{ site.baseurl }}{% link img/plus/unified.png %}) 70 | 71 | ## 下一步 72 | 73 | [配置]({{ site.baseurl }}{% link zh/plus/guide/configuration.md %}) 74 | {: .btn-stylized} 75 | 76 | ## 疑问? 77 | 78 | 我们一直乐于帮您解决可能遇到的问题。搜索我们的文档或查看常见问题的答案。您也可以在我们的社区论坛发布问题或评论。您也可以查看我们在github中的帮助部分 https://github.com/keymetrics/keymetrics-support -------------------------------------------------------------------------------- /zh/plus/guide/issue-dashboard.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: page 3 | title: 问题仪表板 | 指南 | PM2 Plus教程 4 | title-en: Issue Dashboard | Guide | PM2 Plus Documentation 5 | menu: starter 6 | lang: zh 7 | section: plus 8 | --- 9 | 10 | # 问题仪表板 11 | 12 | ![问题仪表板]({{ site.baseurl }}{% link img/plus/issue.png %}) 13 | 14 | 您可以跟踪服务器上发生的所有异常情况: 15 | - 堆栈轨迹 16 | - 在线代码编号 17 | - 异常之前的日志 18 | 19 | 问题仪表板主要报告所有未捕获的异常。 发生时,node.js进程崩溃,PM2自动重启应用,同时提醒异常。 20 | 21 | ## 手动发出一项问题 22 | 23 | 如果您在代码中正确使用 `try ... catch`,则错误将被捕获,且永远不会在仪表板中报告。 24 | 25 | 如还是想收到报告,使用 `io.notify()`发出一个异常情况: 26 | 27 | ```javascript 28 | const io = require('@pm2/io') 29 | 30 | try { 31 | // Critical action to be tested 32 | } 33 | catch(error) { 34 | // Your code in case of an exception 35 | io.notify(new Error('This is an error')) 36 | } 37 | ``` 38 | 39 | ## Express.js中间件 40 | 41 | 默认情况下,express会捕获所有发生的异常。 42 | 43 | 如果您想要报告它们,您需要添加PMX中间件: 44 | 45 | ```javascript 46 | // all your routes here 47 | // app.get((req, res) => {}) 48 | app.use(io.expressErrorHandler()) 49 | ``` 50 | 51 | 在路由声明之后使用它。 52 | {: .tip} 53 | 54 | ## 下一步 55 | 56 | [事务跟踪]({{ site.baseurl }}{% link zh/plus/guide/transaction-tracing.md %}) 57 | {: .btn-stylized} 58 | 59 | ## 疑问? 60 | 61 | 我们一直乐于帮您解决可能遇到的问题。搜索我们的文档或查看常见问题的答案。您也可以在我们的社区论坛发布问题或评论。您也可以看看我们在github中的帮助部分 https://github.com/keymetrics/keymetrics-support 62 | -------------------------------------------------------------------------------- /zh/plus/guide/memory-cpu-profiling.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: page 3 | title: 内存和CPU分析 | 指南 | PM2 Plus教程 4 | title-en: Memory & CPU Profiling | Guide | PM2 Plus Documentation 5 | menu: starter 6 | lang: zh 7 | section: plus 8 | --- 9 | 10 | # 内存和CPU分析 11 | 12 | ![cpu和内存分析]({{ site.baseurl }}{% link img/plus/memory-profiling.png %}) 13 | 14 | 分析工具可帮助您诊断内存和CPU使用情况以及其他应用级别的问题。 15 | 16 | PM2 Plus中的配置文件允许您获取生产服务器的远程CPU/内存快照。 您可以使用chrome开发者工具以准备好相关文件进行检查。 17 | 18 | ## 内存分析 19 | 20 | 点击获取堆转储并下载文件。 这个过程取决于堆文件的权重,可能需要一些时间。 21 | 22 | 使用谷歌Chrome开发者工具检查配置文件标签(**Load**按钮)。 23 | 24 | ### 跟踪内存泄漏 25 | 26 | 要跟踪内存泄漏,您需要比较多个堆转储文件以查看随着时间的推移哪个元素在增加。 27 | 28 | 要详细了解内存分析,请查看[google教程](https://developer.chrome.com/devtools/docs/heap-profiling)。 29 | 30 | ## CPU分析 31 | 32 | 关于CPU分析,您来决定想要记录多久。 33 | 34 | 它为您提供了堆栈的可视化,且仍提供了下载CPU分析文件的功能。 35 | 36 | ## 下一步 37 | 38 | 感谢您读完本指南。 39 | 40 | 您现在可以查看 [reference]({{ site.baseurl }}{% link zh/plus/reference/pmx.md %})来掌握PM2的所有功能。 41 | 42 | ## 疑问? 43 | 44 | 我们一直乐于帮您解决可能遇到的问题。搜索我们的文档或查看常见问题的答案。您也可以在我们的社区论坛发布问题或评论。您也可以看看我们在github中的帮助部分 https://github.com/keymetrics/keymetrics-support 45 | -------------------------------------------------------------------------------- /zh/plus/integration/README.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: page 3 | title: 集成 | PM2 Plus教程 4 | title-en: Integration | PM2 Plus Documentation 5 | menu: starter 6 | lang: zh 7 | section: plus 8 | permalink: "/zh/plus/integration/" 9 | --- 10 | 11 | # 集成 12 | 13 | 本节将帮助您整合PM2。 14 | 15 | 选择最符合您需求的教程: 16 | 17 | - [AWS Elastic Beanstalk]({{ site.baseurl }}{% link zh/plus/integration/elastic-beanstalk.md %}) 18 | - [Docker]({{ site.baseurl }}{% link zh/plus/integration/docker.md %}) 19 | - [Heroku]({{ site.baseurl }}{% link zh/plus/integration/heroku.md %}) 20 | - [使用云供应商]({{ site.baseurl }}{% link zh/plus/integration/cloud-providers.md %}) -------------------------------------------------------------------------------- /zh/plus/integration/cloud-providers.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: page 3 | title: 使用云供应商 | 集成 | PM2 Plus教程 4 | title-en: Cloud Providers | Integration | PM2 Plus Documentation 5 | menu: starter 6 | lang: zh 7 | section: plus 8 | --- 9 | 10 | # 在云供应商中监控您的Node.js应用 11 | 12 | 仅需几秒,本教程将向您展示如何使用`pm2`和云供应商监控node.js应用。 13 | 14 | 我们假设您的应用已被PM2包装了。 如果没有,请按照[云供应商教程]({{ site.baseurl }}{% link zh/runtime/integration/cloud-providers.md %})进行。 15 | 16 | ## 创建一个账户 17 | 18 | 在[此处](https://id.keymetrics.io/api/oauth/register)注册。 19 | 20 | ## 将您的应用与PM2 Plus关联。 21 | 22 | 为了将PM2连接到仪表板,您需要在环境中添加公钥和私钥。 23 | 24 | ```bash 25 | export PM2_PUBLIC_KEY="YYYYY" 26 | export PM2_SECRET_KEY="XXXXXXXXX" 27 | pm2 update 28 | ``` 29 | 30 | ## 在PM2 Plus中设置服务器名称 31 | 32 | 设置`PM2_MACHINE_NAME`环境变量以指定服务器名称: 33 | 34 | ```bash 35 | export PM2_MACHINE_NAME="my-cloud-provider-server" 36 | ``` 37 | 38 | 默认的服务器名称是带有随机字符串的主机名(`HOST`环境变量). 39 | {: .tip} 40 | 41 | 请注意,如果主机名重复,仪表板将接收来自两个实例和闪烁的数据. 42 | {: .tip} 43 | 44 | ## 下一步 45 | 46 | 完成您的[仪表板配置]({{ site.baseurl }}{% link zh/plus/guide/configuration.md %}) 47 | 48 | ## 疑问? 49 | 50 | 我们一直乐于帮您解决可能遇到的问题。搜索我们的文档或查看常见问题的答案。您也可以在我们的社区论坛发布问题或评论。 -------------------------------------------------------------------------------- /zh/plus/integration/docker.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: page 3 | title: Docker | 集成 | PM2 Plus教程 4 | title: Docker | Integration | PM2 Plus Documentation 5 | menu: starter 6 | lang: zh 7 | section: plus 8 | --- 9 | 10 | # 在Docker容器中监控您的Node.js应用 11 | 12 | 只需几秒,本教程将向您展示如何在容器内使用`pm2`监控node.js应用。 13 | 14 | 我们假设您的应用已被PM2包装了。 如果没有,请参考 [docker教程]({{ site.baseurl }}{% link zh/runtime/integration/docker.md %})。 15 | 16 | ## 创建一个账户 17 | 18 | 在 [此处](https://id.keymetrics.io/api/oauth/register)注册。 19 | 20 | ## 安装分析器 21 | 22 | 将其添加到Dockerfile以安装分析器: 23 | 24 | ```Dockerfile 25 | RUN pm2 install profiler 26 | ``` 27 | 28 | ## 将您的应用与PM2 Plus关联 29 | 30 | 为了将PM2连接到仪表板,您需要在环境中添加公钥和私钥. 31 | 32 | 创建一个.env文件: 33 | ```.env 34 | PM2_SECRET_KEY=XXXXX 35 | PM2_PUBLIC_KEY=YYYYY 36 | ``` 37 | 并用`docker run`重启您的容器,并添加`--env-file .env`来加载环境变量。 38 | 39 | ## 在PM2 Plus中设置服务器名称 40 | 41 | 设置 `PM2_MACHINE_NAME`环境变量以指定服务器名称。将此添加到.env文件: 42 | 43 | ```.env 44 | PM2_SECRET_KEY=XXXXX 45 | PM2_PUBLIC_KEY=YYYYY 46 | PM2_MACHINE_NAME=docker-server 47 | ``` 48 | 49 | 默认的服务器名称是带有随机字符串的主机名(`HOST`环境变量). 50 | {: .tip} 51 | 52 | 请注意,如果主机名重复,仪表板将接收来自两个实例和闪烁的数据. 53 | {: .tip} 54 | 55 | ## 下一步 56 | 57 | 完成您的[仪表板配置]({{ site.baseurl }}{% link zh/plus/guide/configuration.md %}) 58 | 59 | ## 疑问? 60 | 61 | 我们一直乐于帮您解决可能遇到的问题。搜索我们的文档或查看常见问题的答案。您也可以在我们的社区论坛发布问题或评论。 62 | 63 | 64 | ### 使用Keymetrics.io仪表板 65 | 66 | [Keymetrics.io](https://keymetrics.io/)是一个建立在PM2之上的监控服务,可以轻松监控和管理应用程序(日志,重启,异常监控等)。 您在Keymetrics上创建了一个Bucket后,您将得到一个公钥和一个密钥。 67 | 68 | 要使用pm2-runtime启用Keymetrics monitoring,您可以使用CLI选项–public `XXXX`和–secret `YYYY`,或您可以传递环境变量`KEYMETRICS_PUBLIC`和`KEYMETRICS_SECRET`。 69 | 70 | 从您的Node.js应用项目文件夹启动这些命令: 71 | 72 | ```bash 73 | $ docker build -t your-app-name . 74 | $ docker run -e KEYMETRICS_PUBLIC=XXXX -e KEYMETRICS_SECRET=YYYY your-app-name 75 | ``` 76 | 77 | 确保防火墙允许端口80 (TCP outbound),443 (HTTPS outbound)和43554 (TCP outbound)。 78 | 79 | 如果遇到任何问题,请参阅[故障排除](http://docs.keymetrics.io/docs/pages/faq-troubleshooting/#troubleshooting-for-keymetrics-pm2)。 -------------------------------------------------------------------------------- /zh/plus/integration/elastic-beanstalk.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: page 3 | title: Elastic Beanstalk | 集成 | PM2 Plus教程 4 | title-en: Elastic Beanstalk | Integration | PM2 Plus Documentation 5 | menu: starter 6 | lang: zh 7 | section: plus 8 | --- 9 | 10 | # 在AWS Elastic Beanstalk中监控您的Node.js应用 11 | 12 | 只需几秒,本教程将向您展示如何在AWS Elastic Beanstalk环境中使用`pm2`监控Node.js应用。 13 | 14 | 我们假设您的应用已被PM2包装了。 如果没有,请参考我们的 [AWS Elastic Beanstalk 教程]({{ site.baseurl }}{% link zh/runtime/integration/elastic-beanstalk.md %})进行。 15 | 16 | ## 在PM2上创建一个帐户 17 | 18 | 您可以在 [这里](https://id.keymetrics.io/api/oauth/register)注册。 19 | 20 | ## 将您的应用与PM2 Plus相关联 21 | 22 | 为了将PM2连接到仪表板,您需要在环境中添加公钥和私钥。 23 | 24 | 将您的密钥注入您的eb环境: 25 | ```bash 26 | eb setenv PM2_PUBLIC_KEY=YYYYY PM2_SECRET_KEY=XXXXXXXX 27 | ``` 28 | 29 | 您可以仪表板右上角访问您的密钥 30 | {: .tip} 31 | 32 | 我们不建议使用生态系统文件将您的密钥设置到您的环境中,如果这样您的生态系统文件可能会被公开。 33 | {: .warn} 34 | 35 | ## 在PM2 Plus中设置服务器名称 36 | 37 | 设置 `PM2_MACHINE_NAME`环境变量以指定服务器名称: 38 | 39 | ```bash 40 | eb setenv PM2_MACHINE_NAME=aws-eb-server 41 | ``` 42 | 43 | 默认的服务器名称是带有随机字符串的主机名(`HOST`环境变量)。 44 | {: .tip} 45 | 46 | 请注意,如果主机名重复,仪表板将接收来自两个实例和闪烁的数据。 47 | {: .tip} 48 | 49 | ## 下一步 50 | 51 | 完成您的 [仪表板配置]({{ site.baseurl }}{% link zh/plus/guide/configuration.md %}) 52 | 53 | ## 疑问? 54 | 55 | 我们一直乐于帮您解决可能遇到的问题。搜索我们的文档或查看常见问题的答案。您也可以在我们的社区论坛发布问题或评论。 -------------------------------------------------------------------------------- /zh/plus/integration/heroku.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: page 3 | title: Heroku | 集成 | PM2 Plus教程 4 | title-en: Heroku | Integration | PM2 Plus Documentation 5 | menu: starter 6 | lang: zh 7 | section: plus 8 | --- 9 | 10 | # 在Heroku中监控您的Node.js应用 11 | 12 | 只需几秒,本教程将向您展示如何使用`pm2`和Heroku监控node.js应用。 13 | 14 | 我们假设您的应用已被PM2包装了。 如果没有,请按照[heroku教程]({{ site.baseurl }}{% link zh/runtime/integration/heroku.md %})进行。 15 | 16 | ## 创建一个账户 17 | 18 | 在[这里](https://id.keymetrics.io/api/oauth/register)注册。 19 | 20 | ## 与PM2 Plus关联 21 | 22 | 为了将PM2连接到仪表板,您需要在环境中添加公钥和私钥。 23 | 24 | 用此添加您的密钥: 25 | 26 | ```bash 27 | heroku config:set PM2_PUBLIC_KEY=XXXXXXXXXX PM2_SECRET_KEY=YYYYY 28 | ``` 29 | 30 | 您可以在仪表板的右上方访问您的密钥 31 | {: .tip} 32 | 33 | ## 在PM2 Plus中设置服务器名称 34 | 35 | 设置 `PM2_MACHINE_NAME`环境变量以指定服务器名称: 36 | 37 | ```bash 38 | heroku config:set PM2_MACHINE_NAME=heroku-server 39 | ``` 40 | 41 | 默认的服务器名称是带有几个随机字符的主机名(`HOST`环境变量). 42 | {: .tip} 43 | 44 | 请注意,如果主机名重复,仪表板将接收来自两个实例和闪烁的数据. 45 | {: .tip} 46 | 47 | ## 下一步 48 | 49 | 完成您的[仪表板配置]({{ site.baseurl }}{% link zh/plus/guide/configuration.md %}) 50 | 51 | ## 疑问? 52 | 53 | 我们一直乐于帮您解决可能遇到的问题。搜索我们的文档或查看常见问题的答案。您也可以在我们的社区论坛发布问题或评论。 -------------------------------------------------------------------------------- /zh/plus/overview.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: page 3 | title: 概述 | PM2 Plus教程 4 | title-en: Overview | PM2 Plus Documentation 5 | menu: starter 6 | lang: zh 7 | section: plus 8 | --- 9 | 10 | # 概述 11 | 12 | 为什么要用PM2监控您的应用? 在PM2监控概述结束时,您将对PM2监测功能有很全面的了解。 13 | 14 | ## 全球仪表板 15 | 16 | ### 统一概述 17 | 18 | ![一个统一概述]({{ site.baseurl }}{% link /img/plus/unified.png %}) 19 | 20 | 通过PM2 Plus,您只需在一个界面即可实时或通过历史记录查看所有应用和数据库的详细信息。 **别再一对一的ssh服务器连接了**,您可以通过精简的基础架构集成式监控,以节省时间 21 | 22 | ### 自定义指标 23 | 24 | ![自定义指标]({{ site.baseurl }}{% link /img/plus/personalized.png %}) 25 | 26 | 公开Node.js应用源代码中的重要变量,并将它们作为性能指标显示在PM2 Plus仪表板上。 **监视重要的值。** 27 | 28 | ### 提醒 29 | 30 | ![提醒]({{ site.baseurl }}{% link /img/plus/notifications.png %}) 31 | 32 | 知道数据何时达到阈值,应用发生错误或运行的应用关闭时。 33 | 34 | 尽管PM2运行时确保您的应用没有停机时间,但在这些重要情况下要确保收到通知才能做出反应。 **在任何特殊情况下都得到通知并做出反应。** 35 | 36 | ## 调试 & 优化 37 | 38 | ### 异常仪表板 39 | 40 | ![异常仪表板]({{ site.baseurl }}{% link img/plus/issue.png %}) 41 | 42 | PM2 Plus会生成Node.js中“异常仪表板”中发生的所有错误列表,并通知您。 43 | 44 | 停止花时间查找错误或尝试重播它们,我们为您提供一个“异常仪表板”,将所有内容放在一处,以便更轻松地进行调试。 **深入解读您的代码并得到解决方案。** 45 | 46 | ### 事物跟踪 47 | 48 | ![事物跟踪]({{ site.baseurl }}{% link img/plus/tracing.png %}) 49 | 50 | 记录和汇总您的应用在每个http请求上所做的数据库和外部调用。 51 | 52 | “事务跟踪”可帮助您排查性能问题,并获得有关您的应用工作情况的详细信息(最慢的路由,耗费,调用数量)。 **提供更好的用户体验,使您的应用运行更快。** 53 | 54 | ### 内存和CPU分析 55 | 56 | ![内存和CPU分析]({{ site.baseurl }}{% link img/plus/memory-profiling.png %}) 57 | 58 | 直接从产品服务器获取内存转储和CPU快照 59 | 60 | **内存分析可让您在应用中发现任何可能存在的内存泄漏问题。CPU分析可帮助您识别高度消耗资源的任务。** 61 | 62 | ## 额外-功能 63 | 64 | ### 远程控制 65 | 66 | ![远程操作]({{ site.baseurl }}{% link img/plus/remote.png %}) 67 | 68 | PM2 Plus使您可以在应用的源代码中增强自定义功能。 69 | 70 | 例如,您可以给应用变量赋值,或者切换到维护模式。换句话说,您可以在 **您的代码中公开可触发函数**。 71 | 72 | ### 第三方模块 73 | 74 | ![模块]({{ site.baseurl }}{% link img/plus/modules.png %}) 75 | 76 | Extend the capabilities of the PM2 dashboard by using external modules listed in our module page. 77 | 通过使用我们模块页面中列出的外部模块来扩展PM2仪表板的功能。 78 | 79 | Pm2模块可以是日志轮换模块,数据库监控模块,一个独立的http代理,一个负载平衡器,一个DNS服务器或任意类型的实用工具。**任何人都可以创建和发布自己的模块。** 80 | 81 | ### 下一步 82 | 83 | [快速入门]({{ site.baseurl }}{% link zh/plus/quick-start.md %}) 84 | {: .btn-stylized} 85 | 86 | ### 疑问? 87 | 88 | 我们一直乐于帮您解决可能遇到的问题。搜索我们的文档或查看常见问题的答案。您也可以在我们的社区论坛发布问题或评论。 89 | 90 | 91 | -------------------------------------------------------------------------------- /zh/plus/quick-start.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: page 3 | title: 快速入门 | PM2 Plus教程 4 | title-en: Quick Start | PM2 Plus Documentation 5 | menu: starter 6 | lang: zh 7 | section: plus 8 | --- 9 | 10 | # 快速入门 11 | 12 | 只需几秒,本快速入门教程将向您展示如何开始使用PM2监控您的node.js应用。 13 | 14 | 我们假设您的应用已启动或使用了PM2包装。 如果没有,请按照[快速入门]({{ site.baseurl }}{% link zh/runtime/quick-start.md %}) 教程进行。 15 | 16 | ## 创建一个帐户 17 | 18 | 在 [此处](https://id.keymetrics.io/api/oauth/register)注册。 19 | 20 | ## 将您的服务器连接到仪表板 21 | 22 | 将您的服务器连接到仪表板并开始收集指标: 23 | 24 | ```bash 25 | pm2 link 26 | ``` 27 | 28 | 或者,如果您无权访问CLI,请添加使用公钥和私钥设置的 `PM2_PUBLIC_KEY`和 `PM2_SECRET_KEY`环境变量。 29 | 30 | 您可以在仪表板的右上方找到密钥和公钥 31 | {: .tip} 32 | 33 | ## 安装CPU/内存分析 34 | 35 | ### g++ 36 | 37 | 您必须安装 `g++`: 38 | 39 | 在Linux上,输入 `sudo apt-get install build-essential`。 40 | 41 | 在Mac上,在终端中输入 `g++`,然后按照说明操作。 42 | 43 | ### CPU/内存分析器 44 | 45 | 使用PM2安装程序: 46 | 47 | ```bash 48 | pm2 install profiler 49 | ``` 50 | 51 | 然后重载您的应用以启用分析器: 52 | 53 | ```bash 54 | pm2 reload all 55 | ``` 56 | 57 | ## 您已完成 58 | 59 | 返回仪表板,您现在已可以访问您应用的实时指标。 60 | 61 | ![仪表板视图]({{ site.baseurl }}{% link img/plus/unified.png %}) 62 | 63 | ## 下一步 64 | 65 | [配置]({{ site.baseurl }}{% link zh/plus/guide/configuration.md %}) 66 | {: .btn-stylized} 67 | 68 | ## 疑问? 69 | 70 | 我们一直乐于帮您解决可能遇到的问题。搜索我们的文档或查看常见问题的答案。您也可以在我们的社区论坛发布问题或评论。您也可以查看我们在github中的帮助部分 https://github.com/keymetrics/keymetrics-support 71 | 72 | 73 | 74 | -------------------------------------------------------------------------------- /zh/runtime/best-practices/README.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: page 3 | title: 生产最佳实践 | PM2教程 4 | title-en: Best Practices | PM2 Documentation 5 | menu: starter 6 | lang: zh 7 | section: runtime 8 | permalink: "/zh/en/zh/runtime/best-practices/" 9 | --- 10 | 11 | # 生产最佳实践 12 | 13 | 本节收集了有关生产最佳实践的内容,以便从一开始就可以扩展您的应用。 14 | 15 | - [Node.js中的环境变量]({{ site.baseurl }}{% link zh/runtime/best-practices/environment-variables.md %}) 16 | - [正常关机]({{ site.baseurl }}{% link zh/runtime/best-practices/graceful-shutdown.md %}) 17 | - [无状态应用]({{ site.baseurl }}{% link zh/runtime/best-practices/stateless-application.md %}) -------------------------------------------------------------------------------- /zh/runtime/best-practices/environment-variables.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: page 3 | title: 中的环境变量 | 生产最佳实践 | PM2教程 4 | title-en: Environment Variables | Best Practices | PM2 Documentation 5 | menu: starter 6 | lang: zh 7 | section: runtime 8 | --- 9 | 10 | # Node.js中的环境变量 11 | 12 | 环境变量是可以在您的Node.js应用之外设置的特殊变量,对于使应用可以在外部进行配置特别有用。 假设是在这样的情况下,云供应商想要更改您应用的侦听端口,或您希望启用详细日志记录而无需进入代码。 13 | 14 | 本教程将向您介绍如何在Node.js中使用环境变量。 15 | 16 | ## 设置环境 17 | 18 | 当使用Node.js启动应用时,您外壳的当前环境将被注入到您的应用环境中。 这些变量在 `process.env.ENV_NAME`中可用 19 | 20 | ## NODE_ENV环境变量 21 | 22 | Node.js中的常见约定是NODE_ENV环境变量指定应用运行的环境(通常是开发或生产)。 23 | 24 | 例如,通过express,将NODE_ENV设置为“production”可根据此[文档](https://expressjs.com/en/advanced/best-practice-performance.html#set-node_env-to-production)将性能提高3倍。 这能: 25 | - 缓存视图模板. 26 | - 缓存CSS扩展生成的CSS文件. 27 | - 生成较少的冗长错误信息。 28 | 29 | 您可以在您的生态系统文件中定义您的不同环境: 30 | 31 | ```javascript 32 | module.exports = { 33 | apps: [{ 34 | name: "app", 35 | script: "./app.js", 36 | env: { 37 | NODE_ENV: "development" 38 | }, 39 | env_production: { 40 | NODE_ENV: "production", 41 | } 42 | }] 43 | } 44 | ``` 45 | 46 | 使用`pm2 start app --env production`在运行模式下启动您的应用。 -------------------------------------------------------------------------------- /zh/runtime/best-practices/stateless-application.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: page 3 | title: 无状态应用 | 生产最佳实践 | PM2教程 4 | title-en: Stateless Application | Best Practices | PM2 Documentation 5 | menu: starter 6 | lang: zh 7 | section: runtime 8 | --- 9 | 10 | # 无状态应用 11 | 12 | 一个无状态应用没有存储进程中的本地数据。 例如,会话/websocket连接,会话内存和其他相关。 13 | 14 | 您必须使用Redis,Mongo或其他数据库来共享进程之间的所有状态。 15 | 16 | 关于如何编写高效的、生产就绪的无状态应用,这里有个关于十二因素应用宣言的有用资源:https://12factor.net/ -------------------------------------------------------------------------------- /zh/runtime/guide/README.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: page 3 | title: 指南 | PM2教程 4 | title-en: Guide | PM2 Documentation 5 | menu: starter 6 | lang: zh 7 | section: runtime 8 | permalink: "/zh/runtime/guide/" 9 | --- 10 | 11 | # 指南 12 | 13 | 本指南将向您展示如何安装和使用pm2以将您的应用设置产出。 14 | 15 | ## 术语 16 | 17 | 开始之前,我们在本指南中使用了以下一些术语: 18 | 19 | 20 | **daemon** 即进程守护,是一个作为后台进程运行的程序。 pm2本质上是一个daemon:总是在后台运行,它会顾及到您所有的进程,使它们运行。另外,您所有以pm2开头的应用都是daemonized,即守护进程的。 21 | 22 | **process list** 即进程列表,是注册您所有应用以及选项和环境的地方。该列表仅包含pm2已启动的所有进程。 23 | 24 | [即刻开始]({{ site.baseurl }}{% link zh/runtime/guide/installation.md %}) 25 | {: .btn-stylized} 26 | -------------------------------------------------------------------------------- /zh/runtime/guide/development-tools.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: page 3 | title: 开发工具 | 指南 | PM2教程 4 | title-en: Development Tools | Guide | PM2 Documentation 5 | menu: starter 6 | lang: zh 7 | section: runtime 8 | --- 9 | 10 | # 开发工具 11 | 12 | PM2附带两个开发工具,可以帮助您在开发阶段的:观测和重启模式以及静态文件服务器。 13 | 14 | ## 观测和重启 15 | 16 | 观测和重启模式可观测当前目录以检测文件更改和自启动。 17 | 18 | 您可以在您的ecosystem.config.js中启用此模式: 19 | 20 | ```javascript 21 | module.exports = { 22 | apps : [{ 23 | name: "app", 24 | script: "./app.js", 25 | watch: true, 26 | }] 27 | } 28 | ``` 29 | 30 | 请注意,观测和重启模式会导致硬重启,且不会发送SIGINT。 31 | {: .tip} 32 | 33 | ### 观测选项 34 | 35 | 您可以使用高级选项来指定要观测的路径或要忽略的路径。 36 | 37 | ```javascript 38 | module.exports = { 39 | apps : [{ 40 | name: "app", 41 | script: "./app.js", 42 | watch: ".", 43 | }] 44 | } 45 | ``` 46 | 47 | - `watch`也可以是一串或一组要观测的路径。 当设置为`true`时,将观测当前目录。 48 | - `ignore_watch`可以是路径或字符串的数组。 它被[chokidar](https://github.com/paulmillr/chokidar#path-filtering)依赖用作一个glob或正则表达式。 49 | - `watch_options`是作为[chokidar](https://github.com/paulmillr/chokidar#api)依赖项的选项给出的对象(PM2使用的默认选项是持久稳固的,且ingoreInitial设置为true) 50 | 51 | 在使用NFS设备时,您需要按照此[chokidar问题](https://github.com/paulmillr/chokidar/issues/242)中的说明设置`usePolling: true`。 52 | 53 | ### 使用CLI 54 | 55 | 观测模式也可以通过CLI使用 56 | 57 | ```bash 58 | pm2 start app.js --watch 59 | ``` 60 | 61 | 但是,请注意,启用 `--watch`时,您必须使用 `pm2 stop --watch `来停止该进程,因为一般的停止不会使观测停止。 62 | 63 | ## 通过HTTP服务静态文件 64 | 65 | PM2可以通过HTTP服务静态文件(如前端应用): 66 | 67 | ```bash 68 | pm2 serve 69 | ``` 70 | 71 | 由于默认值是 `current folder` 和 `8080`,您可以直接使用: 72 | 73 | ```bash 74 | pm2 serve 75 | ``` 76 | 77 | 在生态系统文件中: 78 | 79 | ```javascript 80 | module.exports = { 81 | apps: [{ 82 | name: "static-file", 83 | script: "serve", 84 | env: { 85 | PM2_SERVE_PATH: ".", 86 | PM2_SERVE_PORT: 8080, 87 | }, 88 | }] 89 | } 90 | ``` 91 | 92 | 并以此开始: 93 | 94 | ```bash 95 | pm2 start ecosystem.config.js 96 | ``` 97 | 98 | 所有其他PM2选项仍然可用。 99 | {: .tip} 100 | 101 | ## 下一步 102 | 103 | [使用SSH轻松部署 ]({{ site.baseurl }}{% link en/runtime/guide/easy-deploy-with-ssh.md %}) 104 | {: .btn-stylized} 105 | 106 | ## 疑问? 107 | 108 | 我们一直乐于帮您解决可能遇到的问题。搜索我们的文档或查看常见问题的答案。您也可以在我们的社区论坛发布问题或评论 -------------------------------------------------------------------------------- /zh/runtime/guide/ecosystem-file.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: page 3 | title: 生态系统文件 | 指南 | PM2教程 4 | title-en: Ecosystem File | Guide | PM2 Documentation 5 | menu: starter 6 | lang: zh 7 | section: runtime 8 | --- 9 | 10 | # 生态系统文件 11 | 12 | 当在多个服务器上部署或使用多个CLI参数时,命令行的一种替代方式对于启动您的应用更加方便。 13 | 14 | 生态系统文件的目的是收集您所有应用的选项和环境变量。 15 | 16 | ## 生成一个模版 17 | 18 | 生成一个 `ecosystem.config.js` 模版: 19 | 20 | ```bash 21 | pm2 init 22 | ``` 23 | 24 | 这会生成: 25 | 26 | ```javascript 27 | module.exports = { 28 | apps : [{ 29 | name: "app", 30 | script: "./app.js", 31 | env: { 32 | NODE_ENV: "development", 33 | }, 34 | env_production: { 35 | NODE_ENV: "production", 36 | } 37 | }] 38 | } 39 | ``` 40 | 41 | 有关可用属性的更多信息,请查看[生态系统文件参考]({{ site.baseurl }}{% link zh/runtime/reference/ecosystem-file.md %})。 42 | 43 | ## 使用您的生态系统文件 44 | 45 | ### 常规 46 | 47 | 一次性启动,停止,重启并重载您的所有应用程序: 48 | 49 | ```bash 50 | pm2 start ecosystem.config.js 51 | pm2 stop ecosystem.config.js 52 | pm2 restart ecosystem.config.js 53 | pm2 reload ecosystem.config.js 54 | ``` 55 | 56 | ### 针对特定进程采取行动 57 | 58 | 使用该选项 `--only ` 对特定应用执行操作: 59 | 60 | ```bash 61 | pm2 restart ecosystem.config.js --only app 62 | ``` 63 | 64 | ## 环境变量 65 | 66 | 您可以多次进行申明,每个条目必须遵照此格式 `env_`。 67 | 68 | 在这里,`app`流程可以从两个环境开始:`development` 和 `production`。 69 | 70 | ```javascript 71 | module.exports = { 72 | apps : [{ 73 | name: "app", 74 | script: "./app.js", 75 | env: { 76 | NODE_ENV: "development", 77 | }, 78 | env_production: { 79 | NODE_ENV: "production", 80 | } 81 | }] 82 | } 83 | ``` 84 | 85 | 用 `--env` 标志选择其中的一个: 86 | 87 | ```bash 88 | pm2 start ecosystem.config.js 89 | pm2 start ecosystem.config.js --env production 90 | ``` 91 | 92 | ## 不可变环境 93 | 94 | 一旦添加到您的流程列表中,流程环境是不可变的。 95 | 96 | 将流程添加到流程列表时生成流程环境,使用: 97 | - 当前环境 98 | - 生态系统文件 99 | 100 | 因此,如果您重启具有不同于当前环境或具有新生态系统文件的进程列表,进程环境不会更改。 101 | 102 | 此行为是为了确保应用重启时的一致性。 103 | 104 | ### 更新环境 105 | 106 | 如果您想强制更新,您必须使用 `--update-env` : 107 | 108 | ```bash 109 | # refresh the environment 110 | pm2 restart ecosystem.config.js --update-env 111 | 112 | # switch the environment 113 | pm2 restart ecosystem.config.js --env production --update-env 114 | ``` 115 | 116 | ## 下一步 117 | 118 | [进程管理]({{ site.baseurl }}{% link zh/runtime/guide/process-management.md %}) 119 | {: .btn-stylized} 120 | 121 | ## 疑问? 122 | 123 | 我们一直乐于帮您解决可能遇到的问题。搜索我们的文档或查看常见问题的答案。您也可以在我们的社区论坛发布问题或评论。 -------------------------------------------------------------------------------- /zh/runtime/guide/installation.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: page 3 | title: 安装 | 指南 | PM2教程 4 | title-en: Installation | Guide | PM2 Documentation 5 | menu: starter 6 | lang: zh 7 | section: runtime 8 | --- 9 | 10 | # 安装 11 | 12 | ## 安装PM2 13 | 14 | 使用yarn: 15 | ```bash 16 | yarn global add pm2 17 | ``` 18 | 19 | 使用npm 20 | ```bash 21 | npm install pm2 -g 22 | ``` 23 | 24 | 在debian操作系统下,使用安装脚本: 25 | ```bash 26 | apt update && apt install sudo curl && curl -sL https://raw.githubusercontent.com/Unitech/pm2/master/packager/setup.deb.sh | sudo -E bash - 27 | ``` 28 | 29 | 使用docker,请遵循 [本教程]({{ site.baseurl }}{% link zh/runtime/integration/docker.md %}). 30 | 31 | ### CLI autocompletion CLI自动完成 32 | 33 | 默认情况下,CLI自动完成不与PM2一起安装,我们推荐: 34 | 35 | ```bash 36 | pm2 completion install 37 | ``` 38 | 39 | ### 源地图支持 40 | 41 | 如果存在的话,源地图文件在默认情况下会自动被检测 (`app.js.map` for `app.js`)。 42 | 43 | 什么是源地图文件?如果正使用Babel,Typescript或任何其他Javascript超集,您可能已经注意到堆栈跟踪没有意义,错误不会指向正确的行。源地图文件则可以用来解决这个问题。 44 | {: .tip} 45 | 46 | ## 更新 47 | 48 | 让您的PM2保持最新状态: 49 | 50 | ```bash 51 | npm install pm2 -g && pm2 update 52 | ``` 53 | 54 | `pm2 update` 是必要的,以便刷新pm2的守护进程。 55 | {: .tip} 56 | 57 | ## 下一步 58 | 59 | [生态系统文件]({{ site.baseurl }}{% link zh/runtime/guide/ecosystem-file.md %}) 60 | {: .btn-stylized} 61 | 62 | ## 疑问? 63 | 64 | 我们一直乐于帮您解决可能遇到的问题。搜索我们的文档或查看常见问题的答案。您也可以在我们的社区论坛发布问题或评论。 -------------------------------------------------------------------------------- /zh/runtime/guide/load-balancing.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: page 3 | title: 负载平衡 | 指南 | PM2教程 4 | title-en: Load-Balancing | Guide | PM2 Documentation 5 | menu: starter 6 | lang: zh 7 | section: runtime 8 | --- 9 | 10 | # 负载平衡(群集模式) 11 | 12 | ![scale across all cpu's available]({{ site.baseurl }}{% link img/runtime/cluster-mode.png %}) 13 | 14 | 内置的负载平衡器提供联网的Node.js应用(http(s)/ tcp / udp服务器),可在所有可用的CPU上进行缩放,无需修改任何代码。 15 | 16 | ## 运用 17 | 18 | 用此选项来激活群集模式 `-i `: 19 | 20 | ```bash 21 | pm2 start app.js -i max 22 | ``` 23 | 24 | `max`表示PM2将自动检测可用CPU的数量并尽可能多地运行进程。 25 | 26 | 或通过您的生态系统文件进行 (ecosystem.config.js): 27 | 28 | ```javascript 29 | module.exports = { 30 | apps: [{ 31 | script: "app.js", 32 | instances: "max", 33 | }] 34 | } 35 | ``` 36 | 37 | 此 *instances* 选项可作为: 38 | - 一个整数。 这会在特定数量的群集中展开应用。 39 | - 字符串'最大'。 这将应用分散到所有CPU内核中。 40 | 41 | 您也可以使用一个负整数。 如果有4个核心,`pm2 start -i -1` 将传播3个群集(最大整数)。 42 | {: .tip} 43 | 44 | ## 无状态应用 45 | 46 | 在群集环境中,您首先需要确定您的应用没有内部状态。 47 | 48 | 内部状态通常是存储在其进程中的一些本地数据。 例如,它可以是一组websocket连接或本地会话内存。 改用Redis或其他数据库来共享进程间的状态。 49 | 50 | 查看我们的 [教程]({{ site.baseurl }}{% link zh/runtime/best-practices/stateless-application.md %}),建立您的无状态应用。 51 | 52 | ## 0秒宕机重载 53 | 54 | 当您使用 `restart`时,pm2杀死并重启该进程,所以在短时间内您将无法使用该服务。 55 | 56 | 通过重载,pm2会一一重启所有进程,并始终保持至少一个进程正在运行: 57 | ```bash 58 | pm2 reload 59 | ``` 60 | 61 | 或: 62 | 63 | ```bash 64 | pm2 reload ecosystem.config.js 65 | pm2 reload ecosystem.config.js --only app 66 | ``` 67 | 68 | 如果重装系统没有重载您的应用,超时将回退到经典重启。 69 | 70 | ## 正常开机&关机 71 | 72 | 为了确保所有请求都能在重载中被正确处理,您需要确保您的应用关闭,不留下未答复的请求。 73 | 74 | 正常关机确保在退出应用并关闭所有外部连接之前处理所有剩余的请求。 75 | 76 | 通过我们的[教程]({{ site.baseurl }}{% link zh/runtime/best-practices/graceful-shutdown.md %})获得帮助,设置正常关机。 77 | 78 | ## 群集环境变量 79 | 80 | `NODE_APP_INSTANCE`环境变量用于区分群集。 81 | 82 | 例如,如果您只想在一个群集上运行cronjob,可检查 `process.env.NODE_APP_INSTANCE === 0`是否成立。 83 | 84 | 该变量可在生态系统文件中重命名: 85 | 86 | ```javascript 87 | module.exports = { 88 | apps: [{ 89 | name: "app", 90 | script: "./app.js", 91 | instance_var: "INSTANCE_ID", 92 | }] 93 | } 94 | ``` 95 | 96 | 这对报告名称冲突的 `node-config`软件包非常有用,查看此[问题](https://github.com/Unitech/pm2/issues/2045)。 97 | {: .tip} 98 | 99 | ## 下一步 100 | 101 | [开发工具]({{ site.baseurl }}{% link zh/runtime/guide/development-tools.md %}) 102 | {: .btn-stylized} 103 | 104 | ## 疑问? 105 | 106 | 我们一直乐于帮您解决可能遇到的问题。搜索我们的文档或查看常见问题的答案。您也可以在我们的社区论坛发布问题或评论。 -------------------------------------------------------------------------------- /zh/runtime/guide/log-management.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: page 3 | title: 日志管理 | 指南 | PM2教程 4 | title-en: Log Management | Guide | PM2 Documentation 5 | menu: starter 6 | lang: zh 7 | section: runtime 8 | --- 9 | 10 | # 日志管理 11 | 12 | 日志可以实时获取并存储到您硬盘中。 13 | 14 | 日志格式化的方式,创建日志文件的方式:所有内容都可以自定义。 15 | 16 | ## 访问日志 17 | 18 | ### 实时日志 19 | 20 | ```bash 21 | # all apps logs 22 | pm2 logs 23 | 24 | # only app logs 25 | pm2 logs app 26 | ``` 27 | 28 | ### 日志文件 29 | 30 | 默认情况下,所有日志都被保存到 `$HOME/.pm2/logs`。 31 | 32 | 您可以以此清空所有应用日志: 33 | 34 | ```bash 35 | pm2 flush 36 | ``` 37 | 38 | ## 日志文件配置 39 | 40 | 您可以为日志指定自定义位置。 41 | 42 | ```javascript 43 | module.exports = { 44 | apps: [{ 45 | name: 'app', 46 | script: 'app.js', 47 | output: './out.log', 48 | error: './error.log', 49 | log: './combined.outerr.log', 50 | }] 51 | } 52 | ``` 53 | 54 | - `output` 只是标准输出 (console.log) 55 | - `error` 只是错误输出 (console.error) 56 | - `log` 结合了 `output` 和 `error`, 默认是禁用的 57 | 58 | ### 循环日志 59 | 60 | 如果您想将日志分成多个文件而不是大文件,请使用循环日志logrotate: 61 | 62 | ```bash 63 | pm2 install pm2-logrotate 64 | ``` 65 | 66 | 在[这里](https://github.com/keymetrics/pm2-logrotate)了解如何配置模块。 67 | 68 | ## 合并日志 69 | 70 | 在群集模式下,每个群集都有自己的日志文件。 您可以使用合并选项将所有日志收集到单个文件中: 71 | 72 | ```javascript 73 | module.exports = { 74 | apps: [{ 75 | name: 'app', 76 | script: 'app.js', 77 | output: './out.log', 78 | error: './error.log', 79 | merge_logs: true, 80 | }] 81 | } 82 | ``` 83 | 84 | 日志仍然分为output/error/log 85 | {: .tip} 86 | 87 | ## 禁用日志 88 | 89 | 您可以通过将日志发送到 /dev/null 来禁用日志: 90 | 91 | ```javascript 92 | module.exports = { 93 | apps: [{ 94 | name: 'app', 95 | script: 'app.js', 96 | output: '/dev/null', 97 | error: '/dev/null', 98 | }] 99 | } 100 | ``` 101 | 102 | ## 格式化日志 103 | 104 | ### JSON 105 | 106 | 您可以以JSON格式输出日志: 107 | 108 | ```bash 109 | echo 110 | ``` 111 | 112 | 变为: 113 | 114 | ```json 115 | { 116 | "message": "echo\n", 117 | "timestamp": "2017-02-06T14:51:38.896Z", 118 | "type": "out", 119 | "process_id": 0, 120 | "app_name": "app" 121 | } 122 | ``` 123 | 124 | 在您的生态系统文件中添加此条目: 125 | 126 | `ecosystem file: `"log_type": "json"` 127 | 128 | ### Timestamp format 时间戳格式 129 | 130 | 您可以以添加时间戳来输出日志: 131 | 132 | ```bash 133 | echo 134 | ``` 135 | 136 | 变为: 137 | 138 | ```bash 139 | 12-02-2018: echo 140 | ``` 141 | 142 | 在您的生态系统文件中添加此条目: 143 | 144 | `"log_date_format": "JJ-MM-YYYY"` 145 | 146 | 格式必须遵循moment.js格式,清单在 [此处](https://momentjs.com/docs/#/parsing/string-format/)。 147 | 148 | ## 下一步 149 | 150 | [启动挂钩]({{ site.baseurl }}{% link zh/runtime/guide/startup-hook.md %}) 151 | {: .btn-stylized} 152 | 153 | ## 疑问? 154 | 155 | 我们一直乐于帮您解决可能遇到的问题。搜索我们的文档或查看常见问题的答案。您也可以在我们的社区论坛发布问题或评论 156 | -------------------------------------------------------------------------------- /zh/runtime/guide/process-management.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: page 3 | title: 进程管理 | 指南 | PM2教程 4 | title-en: Process Management | Guide | PM2 Documentation 5 | menu: starter 6 | lang: zh 7 | section: runtime 8 | --- 9 | 10 | # 进程管理 11 | 12 | pm2是一个保存在后台的进程,一个守护进程,负责处理您所有正在运行的进程。 13 | 14 | 我们将学习如何使用pm2管理进程,并探索一个关键概念:进程列表。 15 | 16 | ## 进程列表 17 | 18 | 进程列表是所有正在运行的应用注册的地方。 19 | 20 | 用几条命令管理您的进程列表: 21 | 22 | ```bash 23 | # start and add a process to your list 24 | pm2 start app.js 25 | 26 | # show your list 27 | pm2 ls 28 | 29 | # stop and delete a process from the list 30 | pm2 delete app 31 | ``` 32 | 33 | 当您使用 `pm2 start app.js`时, 两项操作会被执行: 34 | - 该应用在pm2的进程列表中注册 35 | - 该应用在后台启动. 36 | 37 | 进程列表中的默认名称是没有扩展名的脚本名称。使用`--name`或 `-n` 来改变。 38 | {: .tip} 39 | 40 | ## 常规 41 | 42 | 设置好您的进程列表后,每天的操作都会与进程名称一起完成。 43 | 44 | ```bash 45 | # kill the process but keep it in the process list 46 | pm2 stop app 47 | 48 | # start the process again 49 | pm2 start app 50 | 51 | # both stop and start 52 | pm2 restart app 53 | ``` 54 | 55 | 可以一次性指定多个应用: 56 | ```bash 57 | pm2 restart app1 app2 app3 58 | ``` 59 | 60 | 或者,用正则表达式来缩短: 61 | ```bash 62 | pm2 restart /app/ 63 | ``` 64 | 65 | ## 保存您的进程列表 66 | 67 | 您可以由以下方式保存和重新生成您的进程列表: 68 | 69 | ```bash 70 | # save your list in hard disk memory 71 | pm2 save 72 | 73 | # resurrect your list previously saved 74 | pm2 resurrect 75 | ``` 76 | 77 | 您的进程列表保存在 `$HOME/.pm2/dump.pm2`。 78 | {: .tip} 79 | 80 | 接着您可以设置一个 [启动脚本]({{ site.baseurl }}{% link zh/runtime/guide/installation.md %}),通过机器重启来自启动您的进程列表。 81 | 82 | ## 管理任意应用类型 83 | 84 | pm2与其他编程语言兼容,运用这种等值关系: 85 | 86 | ```json 87 | { 88 | ".sh": "bash", 89 | ".py": "python", 90 | ".rb": "ruby", 91 | ".coffee": "coffee", 92 | ".php": "php", 93 | ".pl": "perl", 94 | ".js": "node" 95 | } 96 | ``` 97 | 98 | 如果没有扩展名,该应用将作为二进制文件启动。 99 | {: .tip} 100 | 101 | 比如要在python中启动脚本,请使用: 102 | 103 | ```bash 104 | pm2 start echo.py 105 | ``` 106 | 107 | 如果您想指定解释器的路径,请在您的生态系统文件中操作: 108 | 109 | ```javascript 110 | module.exports = { 111 | "apps" : [{ 112 | name: "script", 113 | script: "./script.py", 114 | interpreter: "/usr/bin/python", 115 | }] 116 | } 117 | ``` 118 | 119 | ## 本地监控 120 | 121 | ![pm2本地监控]({{ site.baseurl }}{% link img/runtime/monit.png %}) 122 | 123 | 本地监控工具可让您了解每个进程的CPU使用情况,内存使用情况,环路延迟或请求/分钟: 124 | 125 | ```bash 126 | pm2 monit 127 | ``` 128 | 129 | ## 下一步 130 | 131 | [日志管理]({{ site.baseurl }}{% link zh/runtime/guide/log-management.md %}) 132 | {: .btn-stylized} 133 | 134 | ## 疑问? 135 | 136 | 我们一直乐于帮您解决可能遇到的问题。搜索我们的文档或查看常见问题的答案。您也可以在我们的社区论坛发布问题或评论。 -------------------------------------------------------------------------------- /zh/runtime/guide/startup-hook.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: page 3 | title: 启动挂钩 | 指南 | PM2教程 4 | title-en: Startup Hook | Guide | PM2 Documentation 5 | menu: starter 6 | lang: zh 7 | section: runtime 8 | --- 9 | 10 | # 启动挂钩 11 | 12 | 启动挂钩的目的是保存您的进程列表,并在计算机重启甚至出现意外时将其恢复。 13 | 14 | 每个操作系统都有一个特定的工具来处理启动挂钩:pm2提供了一种简单的方法来生成和配置它们。 15 | 16 | ## 安装 17 | 18 | 检测计算机上可用的init系统并生成配置,使用: 19 | 20 | ```bash 21 | pm2 startup 22 | $ [PM2] 您必须以root身份运行此命令。 执行以下命令: 23 | $ sudo su -c "env PATH=$PATH:/home/unitech/.nvm/versions/node/v4.3/bin pm2 startup -u --hp 24 | ``` 25 | 26 | 在CLI中复制并粘贴此命令的输出以设置启动挂钩。 27 | 28 | 使用NVM时,此`pm2`路径会在更新Node.js时改变。 每次更新后您都需要运行`startup`命令。 29 | {: .warn} 30 | 31 | 您可以通过`--service-name `选项自定义服务名称 ([#3213](https://github.com/Unitech/pm2/pull/3213)) 32 | {: .tip} 33 | 34 | ## 保存您的进程列表 35 | 36 | 启动挂钩会自动加载您之前保存的进程列表。 37 | 38 | 以此来保存您的进程列表: 39 | 40 | ```bash 41 | pm2 save 42 | ``` 43 | 44 | ## 禁用启动系统 45 | 46 | ```bash 47 | pm2 unstartup 48 | ``` 49 | 50 | ## 用户权限 51 | 52 | 如果您希望启动挂钩在其他用户下执行,使用 `-u `和 `--hp `选项: 53 | 54 | ```bash 55 | pm2 startup ubuntu -u www --hp /home/ubuntu 56 | ``` 57 | 58 | ## 更新启动挂钩 59 | 60 | 要更新启动挂钩,请运行以下命令: 61 | 62 | ```bash 63 | pm2 unstartup 64 | pm2 startup 65 | ``` 66 | 67 | ## 兼容性 68 | 69 | 支持的Init系统是: 70 | 71 | - **systemd**: Ubuntu >= 16, CentOS >= 7, Arch, Debian >= 7 72 | - **upstart**: Ubuntu <= 14 73 | - **launchd**: Darwin, MacOSx 74 | - **openrc**: Gentoo Linux, Arch Linux 75 | - **rcd**: FreeBSD 76 | - **systemv**: Centos 6, Amazon Linux 77 | 78 | 如果您愿意,您可以指定使用平台: 79 | 80 | ```bash 81 | pm2 [startup | unstartup] [platform] 82 | ``` 83 | 84 | 平台可以是下列其中一个: 85 | 86 | `[ubuntu | ubuntu14 | ubuntu12 | centos | centos6 | arch | oracle | amazon | macos | darwin | freebsd | systemd | systemv | upstart | launchd | rcd | openrc]` 87 | 88 | ## 在后台 89 | 90 | - **ubuntu** 使用 `updaterc.d` 和脚本 `lib/scripts/pm2-init.sh` 91 | - **centos**/**redhat** 使用 `chkconfig` 和脚本 `lib/scripts/pm2-init-centos.sh` 92 | - **gentoo** 使用 `rc-update` 和脚本 `lib/scripts/pm2` 93 | - **systemd** 使用 `systemctl` 和脚本 `lib/scripts/pm2.service` 94 | - **darwin** 使用 `launchd` 来加载一个特定的 `plist` 以便在重启后复活进程. 95 | 96 | ## 关于windows 97 | 98 | 有一些外部库可以生成一个与Windows兼容的启动脚本,请查看[pm2-windows-service](https://www.npmjs.com/package/pm2-windows-service) 或 [pm2-windows-startup](https://www.npmjs.com/package/pm2-windows-startup). 99 | 100 | ## 下一步 101 | 102 | [负载平衡 (群集模式)]({{ site.baseurl }}{% link zh/runtime/guide/load-balancing.md %}) 103 | {: .btn-stylized} 104 | 105 | ## 疑问? 106 | 107 | 我们一直乐于帮您解决可能遇到的问题。搜索我们的文档或查看常见问题的答案。您也可以在我们的社区论坛发布问题或评论。 108 | -------------------------------------------------------------------------------- /zh/runtime/integration/README.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: page 3 | title: 综合 | PM2教程 4 | title-en: Integration | PM2 Documentation 5 | menu: starter 6 | lang: zh 7 | section: runtime 8 | permalink: "/zh/runtime/integration/" 9 | --- 10 | 11 | # 综合 12 | 13 | 本节将帮助您整合pm2。 14 | 15 | 选择您需要的教程: 16 | 17 | - [AWS Elastic Beanstalk]({{ site.baseurl }}{% link zh/runtime/integration/elastic-beanstalk.md %}) 18 | - [Docker]({{ site.baseurl }}{% link zh/runtime/integration/docker.md %}) 19 | - [Heroku]({{ site.baseurl }}{% link zh/runtime/integration/heroku.md %}) 20 | - [转化器]({{ site.baseurl }}{% link zh/runtime/integration/transpilers.md %}) 21 | - [使用云供应商]({{ site.baseurl }}{% link zh/runtime/integration/cloud-providers.md %}) -------------------------------------------------------------------------------- /zh/runtime/integration/cloud-providers.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: page 3 | title: 使用云供应商 | 综合 | PM2教程 4 | title-en: Cloud Providers | Integration | PM2 Documentation 5 | menu: starter 6 | lang: zh 7 | section: runtime 8 | --- 9 | 10 | # 在云供应商中使用PM2 11 | 12 | 您可能会发现自己处于一个无法访问CLI来启动Node.js应用的情况下。 13 | 14 | 在这种情况下,必须将pm2作为依赖项添加,且必须使用启动脚本调用。 15 | 16 | ## 准备您的应用 17 | 18 | ### 设置您的生态系统文件 19 | 20 | 使用以下命令生成一个 `ecosystem.config.js`模版: 21 | 22 | ```bash 23 | pm2 init 24 | ``` 25 | 26 | 修改生态系统文件以符合您的需求: 27 | 28 | ```javascript 29 | module.exports = { 30 | apps : [{ 31 | name: "app", 32 | script: "./app.js", 33 | env: { 34 | NODE_ENV: "development", 35 | }, 36 | env_production: { 37 | NODE_ENV: "production", 38 | } 39 | }] 40 | } 41 | ``` 42 | 43 | 在[此处]({{ site.baseurl }}{% link zh/runtime/guide/ecosystem-file.md %})了解更多有关生态系统文件的内容 44 | {: .tip} 45 | 46 | ### 将PM2添加为模块 47 | 48 | 将pm2作为依赖项添加到您的项目中。 49 | 50 | 使用npm: 51 | 52 | ```bash 53 | npm install --save pm2 54 | ``` 55 | 56 | 使用yarn: 57 | 58 | ```bash 59 | yarn add pm2 60 | ``` 61 | 62 | ### package.json中启动脚本 63 | 64 | 在您的`package.json`中,修改`start`脚本,如下所示: 65 | 66 | ```json 67 | { 68 | "scripts": { 69 | "start": "node ./node_modules/.bin/pm2-runtime start ecosystem.config.js --env production" 70 | } 71 | ``` 72 | 73 | ## 部署您的应用 74 | 75 | 现在,您可以将应用部署到您的云供应商中,就像您对常规node.js应用所做的那样。 76 | 77 | ## 下一步 78 | 79 | 使用[生态系统文件]({{ site.baseurl }}{% link zh/runtime/guide/ecosystem-file.md %})完成您的配置 80 | 81 | 使用 [PM2 Plus]({{ site.baseurl }}{% link zh/plus/integration/docker.md %})在仪表板上监控您的应用 82 | 83 | ## 疑问? 84 | 85 | 我们一直乐于帮您解决可能遇到的问题。搜索我们的文档或查看常见问题的答案。您也可以在我们的社区论坛发布问题或评论。 -------------------------------------------------------------------------------- /zh/runtime/integration/heroku.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: page 3 | title: Heroku | 综合 | PM2教程 4 | title-en: Heroku | Integration | PM2 Documentation 5 | menu: starter 6 | lang: zh 7 | section: runtime 8 | --- 9 | 10 | # 与Heroku一起使用PM2 11 | 12 | 此页面将逐步引导您通过使用Heroku进行PM2集成。 13 | 14 | 我们将使用Git和Heroku CLI. 15 | 16 | ## 准备您的应用 17 | 18 | ### 设置您的生态系统文件 19 | 20 | 使用以下命令生成一个 `ecosystem.config.js`模板: 21 | 22 | ```bash 23 | pm2 init 24 | ``` 25 | 26 | 修改生态系统文件以符合您的需求: 27 | 28 | ```javascript 29 | module.exports = { 30 | apps : [{ 31 | name: "app", 32 | script: "./app.js", 33 | instances: "max", 34 | env: { 35 | NODE_ENV: "development", 36 | }, 37 | env_production: { 38 | NODE_ENV: "production", 39 | } 40 | }] 41 | } 42 | ``` 43 | 44 | 在[此处]({{ site.baseurl }}{% link zh/runtime/guide/ecosystem-file.md %})了解更多有关生态系统文件的内容。 45 | {: .tip} 46 | 47 | 我们建议在结合群集模式使用Heroku,因为每个dyno都有多核CPU。 48 | 49 | 详细了解 [群集模式]({{ site.baseurl }}{% link zh/runtime/guide/load-balancing.md %}) 50 | {: .tip} 51 | 52 | ### 将PM2添加为模块 53 | 54 | 将pm2作为依赖项添加到您的项目中。 55 | 56 | 使用npm: 57 | 58 | ```bash 59 | npm install --save pm2 60 | ``` 61 | 62 | 使用yarn: 63 | 64 | ```bash 65 | yarn add pm2 66 | ``` 67 | 68 | ### 设置您的package.json 69 | 70 | 在您的 `package.json`中,像下面这样修改您的 `start`脚本: 71 | 72 | ```json 73 | { 74 | "scripts": { 75 | "start": "node ./node_modules/.bin/pm2-runtime start ecosystem.config.js --env production" } 76 | ``` 77 | 78 | ## 用Heroku部署 79 | 80 | ### 在Heroku上创建一个帐户 81 | 82 | 在[这里](https://signup.heroku.com/)注册Heroku帐户。 83 | 84 | ### 安装CLI 85 | 86 | 按照说明在[这里](https://devcenter.heroku.com/articles/heroku-cli)安装。 87 | 88 | 然后,运行 `heroku login`将CLI连接到您的帐户。 89 | 90 | ### 初始化您的Heroku应用 91 | 92 | 我们将首先在Heroku和关联的空Git存储库上创建一个新的空应用。 93 | 94 | 从您的应用根文件夹运行此命令: 95 | ```bash 96 | heroku create 97 | 98 | Creating app... done, ⬢ guarded-island-32432 99 | https://guarded-island-32432.herokuapp.com/ | https://git.heroku.com/guarded-island-32432.git 100 | ``` 101 | 102 | 您现在有一个名为 `heroku`的新git remote。 如果您推送到此存储库,您的代码将自动部署在给定的URL处。 103 | 104 | ### 在Heroku上部署您的应用 105 | 106 | 添加并提交您的所有更改,然后运行: 107 | 108 | ```bash 109 | git push heroku master 110 | Initializing repository, done. 111 | updating 'refs/heads/master' 112 | remote: Compressing source files... done. 113 | remote: Building source: 114 | ... 115 | remote: 116 | remote: Verifying deploy... done. 117 | To https://git.heroku.com/aqueous-temple-78487.git 118 | ``` 119 | 120 | ## 您准备好了 121 | 122 | 就是这样! 部署的最后一行将为您提供应用程序可用的URL。 123 | 124 | ## 下一步 125 | 126 | 使用[生态系统文件]({{ site.baseurl }}{% link zh/runtime/guide/ecosystem-file.md %})完成您的配置 127 | 128 | 使用 [PM2 Plus]({{ site.baseurl }}{% link zh/plus/integration/docker.md %})在仪表板上监控您的应用 129 | 130 | ### 疑问? 131 | 132 | 我们一直乐于帮您解决可能遇到的问题。搜索我们的文档或查看常见问题的答案。您也可以在我们的社区论坛发布问题或评论。 -------------------------------------------------------------------------------- /zh/runtime/integration/transpilers.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: page 3 | title: 转化器 | 综合 | PM2教程 4 | title-en: Transpilers | Integration | PM2 Documentation 5 | menu: starter 6 | lang: zh 7 | section: runtime 8 | --- 9 | 10 | # 与转化器一起使用PM2 11 | 12 | 本教程将向您展示如何在转化器中使用pm2。 13 | 14 | 我们强烈建议不要在**production**中使用它,因为它会减慢您的应用运行。 在这种情况下,您的应用必须被捆绑,即从源代码转换来获取应用的预处理版本. 15 | {: .warn} 16 | 17 | ## Babel Babel 18 | 19 | ```bash 20 | ## Install the Babel CLI globally: 21 | npm install -g babel-cli 22 | 23 | ## Start pm2 with the Babel CLI binary in watch mode: 24 | pm2 start --watch --interpreter babel-cli app.js 25 | ``` 26 | 27 | 或者,您可以创建一个其他文件,这需要转译器和您的应用: 28 | ```javascript 29 | // index.js 30 | require('babel-register'); 31 | require('./app.js'); 32 | ``` 33 | 然后,运行: 34 | ```bash 35 | pm2 start --watch index.js 36 | ``` 37 | 38 | 群集模式仅在第二个选项中可用。 39 | {: .tip} 40 | 41 | ## Coffee-script 42 | 43 | ```bash 44 | ## Install Coffee Script globally: 45 | npm install -g babel-cli 46 | 47 | ## Start pm2 with coffee binary in watch mode: 48 | pm2 start --watch --interpreter coffee app.coffee 49 | ``` 50 | 51 | 或者,您可以创建一个其他文件,这需要转译器和您的应用: 52 | ```javascript 53 | // index.js 54 | require('coffee/register'); 55 | require('./app.coffee'); 56 | ``` 57 | 然后,运行: 58 | ```bash 59 | pm2 start --watch index.js 60 | ``` 61 | 62 | 群集模式仅在第二个选项中可用。 63 | {: .tip} -------------------------------------------------------------------------------- /zh/runtime/overview.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: page 3 | title: 概述 | PM2教程 4 | title-en: Overview | PM2 Documentation 5 | menu: starter 6 | lang: zh 7 | section: runtime 8 | permalink: "/zh/runtime/overview/" 9 | --- 10 | 11 | # 概述 12 | 13 | 为什么使用pm2? 看完这篇介绍,您将更好地理解使用pm2作为进程管理器的好处。 14 | 15 | ## 持久化 16 | 17 | 一旦开始使用,您的应用将达到持久化,在崩溃和机器重启时自启动。 18 | 19 | 这与运行一样简单: 20 | ```bash 21 | pm2 start app.js 22 | ``` 23 | 24 | ## 进程管理 25 | 26 | 您所有的应用都被守护进程,例如,在后台持续运行。 27 | 28 | pm2会创建一个您可以访问的进程列表: 29 | 30 | ```bash 31 | pm2 ls 32 | ``` 33 | 34 | ![pm2 listing]({{ site.baseurl }}{% link img/runtime/pm2ls.png %}) 35 | 36 | 用`pm2 start` 和 `pm2 delete` 管理您的进程列表。 37 | 38 | 在添加到您的进程列表中后,使用 `pm2 start` ,`pm2 stop`,`pm2 restart`来管理进程。 39 | 40 | 41 | 42 | ## 日志管理 43 | 44 | 所有的应用日志都会保存到您的服务器硬盘中`~/.pm2/logs/`。 45 | 46 | ```bash 47 | pm2 logs 48 | ``` 49 | 50 | ## 零配置负载均衡器 51 | 52 | pm2通过创建多个共享相同服务器端口的子进程来扩展您的应用。这样您可以在停机时间为零的情况下重启您的应用。 53 | 54 | 开始群集化您的应用: 55 | ```bash 56 | pm2 start -i max 57 | ``` 58 | 59 | ## 终端内监控 60 | 61 | 在终端中监控您的应用以检查您的应用运行状况(CPU使用情况,内存使用,请求/分钟以及更多): 62 | 63 | ```bash 64 | pm2 monit 65 | ``` 66 | 67 | ![local monitoring with pm2]({{ site.baseurl }}{% link img/runtime/monit.png %}) 68 | 69 | ## 使用SSH轻松部署 70 | 71 | 自动完成部署,不需一对一的ssh服务器连接。 72 | 73 | ```bash 74 | pm2 deploy 75 | ``` 76 | 77 | ## 下一步 78 | 79 | [快速开始]({{ site.baseurl }}{% link zh/runtime/quick-start.md %}) 80 | {: .btn-stylized} 81 | 82 | ## 疑问? 83 | 84 | 我们一直乐于帮您解决可能遇到的问题。搜索我们的文档或查看常见问题的答案。您也可以在我们的社区论坛发布问题或评论。 85 | -------------------------------------------------------------------------------- /zh/runtime/quick-start.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: page 3 | title: 快速入门 | PM2教程 4 | title-en: Quick Start | PM2 Documentation 5 | menu: starter 6 | lang: zh 7 | section: runtime 8 | --- 9 | 10 | # 快速入门 11 | 12 | 只需几秒,本快速入门教程将向您展示如何运用pm2来作用于node.js应用。 13 | 14 | ## 安装 15 | 16 | 使用yarn: 17 | ```bash 18 | yarn global add pm2 19 | ``` 20 | 21 | 使用npm: 22 | ```bash 23 | npm install pm2 -g 24 | ``` 25 | 26 | 在debian操作系统下,使用安装脚本: 27 | 28 | ```bash 29 | apt update && apt install sudo curl && curl -sL https://raw.githubusercontent.com/Unitech/pm2/master/packager/setup.deb.sh | sudo -E bash - 30 | ``` 31 | 32 | 使用docker,请遵循[本教程]({{ site.baseurl }}{% link zh/runtime/integration/docker.md %})。 33 | 34 | ### CLI自动完成 35 | 36 | 我们建议您安装CLI自动完成: 37 | 38 | ```bash 39 | pm2 completion install 40 | ``` 41 | 42 | ## 管理多个进程 43 | 44 | pm2保存您的进程列表,以便可以轻松启动,重启和停止它们。 45 | 46 | ### 进程列表 47 | 48 | 用仅仅几步命令管理您的进程列表: 49 | 50 | ```bash 51 | # start and add a process to your list 52 | pm2 start app.js 53 | 54 | # show your list 55 | pm2 ls 56 | 57 | # stop and delete a process from the list 58 | pm2 delete app 59 | ``` 60 | 61 | 默认进程名称是没有 `.js` 的文件名(例如: `app` for `app.js`). 使用 `--name`或 `-n` 来更改。 62 | {: .tip} 63 | 64 | ### 常规 65 | 66 | 设置您的进程列表后,每天只需使用进程名称来工作。 67 | 68 | ```bash 69 | # stop the process (kill the process but keep it in the process list) 70 | pm2 stop app 71 | 72 | # start the process 73 | pm2 start app 74 | 75 | # both stop and start 76 | pm2 restart app 77 | ``` 78 | 79 | 您也可以设置一个 [启动脚本]({{ site.baseurl }}{% link zh/runtime/guide/installation.md %}), 以便在机器重启时自启动您的进程列表。 80 | 81 | ## 访问您的日志 82 | 83 | 使用`pm2 logs app`**实时**访问您的日志。 84 | 85 | 在 `~/.pm2/logs`文件夹中查看日志**历史**文件。 86 | 87 | ## 群集化 88 | 89 | 群集模式可将您的应用扩展到所有可用的CPU,无需修改任何代码。 90 | 91 | 在使用负载平衡器之前,请确保您的应用是无状态的,这意味着没有本地数据存储在进程中(会话/ WebSocket连接,会话内存以及一些相关内容)。 92 | {: .tip} 93 | 94 | 要以群集模式启动,请传递-i选项,然后传递您所需的群集数: 95 | 96 | ```bash 97 | pm2 start app.js -i 4 98 | ``` 99 | 100 | 或者,自动检测可用的CPU数量: 101 | 102 | ```bash 103 | pm2 start app.js -i max 104 | ``` 105 | 106 | 使用重载而不是重启来实现无中断式重载: 107 | 108 | ```bash 109 | pm2 reload app 110 | ``` 111 | 112 | ## 使用CLI进行更多操作 113 | 114 | 使用制表符,您可以使用自动完成功能: 115 | 116 | ![pm2自动完成]({{ site.baseurl }}{% link img/runtime/autocomplete.png %}) 117 | 118 | 使用 `--help`获得更多关于指令的信息: 119 | 120 | ![pm2帮助]({{ site.baseurl }}{% link img/runtime/help.png %}) 121 | 122 | ## 下一步 123 | 124 | [生态系统文件]({{ site.baseurl }}{% link zh/runtime/guide/ecosystem-file.md %}) 125 | {: .btn-stylized} 126 | 127 | ## 疑问? 128 | 129 | 我们一直乐于帮您解决可能遇到的问题。搜索我们的文档或查看常见问题的答案。您也可以在我们的社区论坛发布问题或评论。 130 | 131 | 132 | -------------------------------------------------------------------------------- /zh/runtime/reference/README.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: page 3 | title: 参考 | PM2教程 4 | title-en: Reference | PM2 Documentation 5 | menu: starter 6 | lang: zh 7 | section: runtime 8 | permalink: "/zh/runtime/reference/" 9 | --- 10 | 11 | # 参考 12 | 13 | 有三个参考可用: 14 | 15 | - [生态系统文件参考]({{ site.baseurl }}{% link zh/runtime/reference/ecosystem-file.md %}) 16 | 17 | 生态系统文件中所有可用选项的完整说明。 18 | 19 | - [CLI参考]({{ site.baseurl }}{% link zh/runtime/reference/pm2-cli.md %}) 20 | 21 | 有关可用CLI命令的完整说明。 22 | 23 | - [编程参考]({{ site.baseurl }}{% link zh/runtime/reference/pm2-programmatic.md %}) 24 | 25 | 以编程方式使用pm2时可用的所有方法的完整说明。 -------------------------------------------------------------------------------- /zh/runtime/reference/ecosystem-file.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: page 3 | title: 生态系统文件 | 参考 | PM2教程 4 | title-en: Ecosystem File | Reference | PM2 Documentation 5 | menu: starter 6 | lang: zh 7 | section: runtime 8 | --- 9 | 10 | # 生态系统文件参考 11 | 12 | ## 选项 13 | 14 | 条目名称|描述|类型|默认 15 | ---|---|---|--- 16 | script|要启动的脚本路径,必填字段|string| 17 | name|进程列表中的进程名称|string|没有扩展名的脚本文件名(app.js的应用) 18 | cwd|当前工作目录以启动进程|string|当前环境的CWD(来自您的shell) 19 | args|传递给脚本的参数|array,string| 20 | interpreter|解释器绝对路径|string|node 21 | node_args|参与传递给解释器|array,string| 22 | output|studout的文件路径(每行都附加到该文件中)|string|~/.pm2/logs/-out.log 23 | error|stderr的文件路径(每行都附加到此文件中)|string|~/.pm2/logs/-error.err 24 | log|组合stdout和stderr的文件路径(每行都附加到此文件中)|boolean,string|/dev/null 25 | disable_logs|禁用所有日志存储|boolean| 26 | log_type|定义一个特定的日志输出类型,可能的值为:json|string| 27 | log_date_format|日志时间戳的格式,采用moment.js格式(例如YYYY-MM-DD HH:mm Z)|string| 28 | env|指定要注入的环境变量|object,string| 29 | ^env_\S*$|指定使用--env 时要注入的环境变量|object,string| 30 | max_memory_restart|如果超出内存量,重新启动应用(格式:/ [0-9](K|M|G)?/ K for KB, 'M' for MB, 'G' for GB, 默认为B)|string,number| 31 | pid_file|pm2写入已启动进程的pid的文件路径|string|~/.pm2/pids/app_name-id.pid 32 | restart_delay|在重启崩溃应用前,需要等待毫秒|number| 33 | source_map_support|启用或禁用源映射支持|boolean|true 34 | disable_source_map_support|启用或禁用源映射支持|boolean| 35 | wait_ready|让进程等待process.send('ready')|boolean| 36 | instances|在群集模式下启动的实例数|number|1 37 | kill_timeout|在SIGINT之后发送最终的SIGKILL信号之前,以ms为单位等待|number|1600 38 | listen_timeout|时间以毫秒为单位,如果应用仍未收听/仍然无发送准备就绪,则强制重载|number| 39 | cron_restart|一个cron模式来重启您的应用|string| 40 | merge_logs|在群集模式下,将每种类型的日志合并到一个文件中(而不是每个群集都单独一个)|boolean| 41 | vizion|启用或禁用版本控制元数据(vizion库)|boolean|true 42 | autorestart|进程失败后启用或禁用自重启|boolean|true 43 | watch|启用或禁用观察模式|boolean,array,string| 44 | ignore_watch|要忽略的路径列表(正则表达式)|array,string| 45 | watch_options|用作chokidar选项的对象(请参阅chokidar文档)|object| 46 | min_uptime|考虑应用启动的最小正常运行时间(格式为/[0-9]+(h|m|s)?/, 小时,分钟,秒,默认为毫秒)|number,string|1000 47 | max_restarts|脚本存在小于最小运行时间时退出的次数|number|16 48 | exec_mode|设置执行模式,可能的值为:fork|群集| cluster|string|fork 49 | force|即使脚本已经运行,也要将其启动(只考虑脚本路径)|boolean| 50 | append_env_to_name|将环境名称附加到应用名称|boolean| 51 | post_update|在从Keymetrics仪表板执行提取/升级操作之后执行的命令列表|array| 52 | trace|启用或禁用事务跟踪|boolean| 53 | disable_trace|启用或禁用事务跟踪|boolean|true 54 | increment_var|指定环境变量的名称以注入每个群集的增量|string| 55 | instance_var|重命名NODE_APP_INSTANCE环境变量|string|NODE_APP_INSTANCE 56 | pmx|启用或禁用pmx包装|boolean|true 57 | automation|启用或禁用pmx包装|boolean|true 58 | treekill|只kill主进程,不分离子进程|boolean|true 59 | port|注入PORT环境变量的快捷方式|number| 60 | uid|设置用户ID|string|当前用户uid 61 | gid|设置群组ID|string|当前用户uid 62 | --------------------------------------------------------------------------------