SlideShare une entreprise Scribd logo
1  sur  48
Télécharger pour lire hors ligne
• CEO & Founder at
• Author of
• Full Stack Javascript developer
• Technologist
My app is ready, now what?
Deploying to production is complex
• Oh noes why my app only use 10% of my server CPUs?
• Oh noes which app is leaking memory?
• Why the server went out of memory?
• Oh noes my app crashed!
• Where are my damn logs?
• How do I organize my micro service app?
• …. …. …. ….
Production application toolbox
with a Built-in load balancer
that Guarantees Uptime
and help you manage your processes
App #1
App #2
App #3
App #4
App #1
App #3 App #4
CL1 CL2
CL3 CL4
Disorganized
application & workflow
Structured
application & workflow
To
Before After
App #1
App #3 App #4
UsabilityCPU
Memory
Log
DeploymentModules
CL1 CL2
CL3 CL4
Ressources
management
and
optimization
Easier
software
management
Extend
capabilities
PM2: Some figures
• 10.000+ stars on GitHub
• 2.000.000+ downloads
• 2500+ commits
• 120+ contributors
• 750+ tests
100+ contributors
Thank you all!!
Installation
Installing PM2
$ npm install pm2 -g
Source code:
https://github.com/Unitech/pm2
Documentation:
http://pm2.keymetrics.io
Setup PM2
No setup required! But…
$ pm2 completion install
Enabling autocompletion:
$ pm2 startup
Respawning PM2 on server boot:
http://pm2.keymetrics.io/docs/usage/quick-start/
Launching apps
Launching a Node.js application
$ pm2 start app.js
Put application in background
Handle logs
Monitor
Auto respawn application
Launching any kind of application
$ pm2 start app.py —interpreter="python3"
$ pm2 start script.sh
Starting a bash script:
Starting a Python app & set interpreter
http://pm2.keymetrics.io/docs/usage/process-management/
Acting on processes
$ pm2 delete <app-name|app-id|'all'>
$ pm2 restart <app-name|app-id|'all'>
Restart:
Delete:
$ pm2 stop <app-name|app-id|'all'>
Stop:
http://pm2.keymetrics.io/docs/usage/process-management/
Cluster mode
Most Node.js application…
Why using the cluster mode?
Intel® Xeon® Processor E5-1410 v2 - 8 cores
Starting an application cluster mode
$ pm2 start app.js -i <instances>
http://pm2.keymetrics.io/docs/usage/cluster-mode/
Managing clustered applications
$ pm2 gracefulReload <app-name|'all'>
$ pm2 reload <app-name|'all'>
Reload without downtime:
Graceful Reload (send signal to process):
$ pm2 scale <app-name> <instances>
Scale up/down process number:
http://pm2.keymetrics.io/docs/usage/cluster-mode/
Inspecting applications
$ pm2 list
Listing processes
$ pm2 monit
Monitoring CPU & Memory
$ pm2 show <app-name|id>
More informations
Inspecting logs
$ pm2 flush
$ pm2 logs [app-name]
Display logs in realtime:
Flushing logs:
$ pm2 reloadLogs
Reloading logs (logrotate):
http://pm2.keymetrics.io/docs/usage/log-management/
Organizing applications
Starting your micro service app…
$ DEBUG=“*” NODE_ENV="production" pm2 start app-1.js —
name “API” -i 8 —watch —max-memory-restart=“300M” — -a 23
$ DEBUG=“app2:*” NODE_ENV=“production" pm2 start
app-2.js —name “WORKER" —watch — -a prod
$ DEBUG=“app3:*” NODE_ENV=“production" pm2 start
app-3.js —name “BDD" —watch — -a malo
UGLY
Solution: JSON declaration
Application 1 (API)
Application 2 (Worker)
Application 3 (Crawler)
ecosystem.json
Using the JSON declaration
$ pm2 restart ecosystem.json
$ pm2 start ecosystem.json
Start:
Restart:
$ pm2 stop <app-name|app-id|'all'>
Stop:
http://pm2.keymetrics.io/docs/usage/application-declaration/
Deployment system
Extending the previous JSONecosystem.json
Production env
Staging env
Multi host
Deployment commands
$ pm2 deploy ecosystem.json production
$ pm2 deploy ecosystem.json production setup
Setup remote server:
Update remote application:
Revert to the n-th deployment:
$ pm2 deploy ecosystem.json production revert [n]
http://pm2.keymetrics.io/docs/usage/deployment/
Modules
What is a module?
An app that extend PM2 capabilities
or
A worker process providing an API
or
A totally independant software
Installing a module
$ pm2 install <module-name>
It gets the module from NPM
then Start it
and Keep it alive forever
http://docs.keymetrics.io/docs/usage/building-module/
Managing modules
$ pm2 uninstall <module-name>
$ pm2 install <module-name>
Install a module:
Uninstall:
$ pm2 set <module-name>:<attr> <value>
Set configuration option:
http://docs.keymetrics.io/docs/usage/building-module/
Some modules
Module #1: pm2-logrotate
$ pm2 install pm2-logrotate
Automatically rotate all logs of applications
managed by pm2
https://github.com/pm2-hive/pm2-logrotate
Module #2: pm2-webshell
$ pm2 install pm2-webshell
Expose a fully capable terminal in your browser
https://github.com/pm2-hive/pm2-webshell
Module #2: pm2-webshell
Termcaps capable
Backed by TTY.js
HTTPS support
Pass/User configurable
Port
Module #x: pm2-technology
Module #x: pm2-technology
Writing your own module
$ pm2 module:generate sample-module
Create a sample module:
Documentation:
Google -> pm2 module system
Official modules repositories:
http://github.com/pm2-hive/
Thank you!
alexandre@keymetrics.io
github.com/Unitech
@strzel_a

Contenu connexe

Tendances

How to successfully migrate to Bazel from Maven or Gradle - Riga Dev Days
How to successfully migrate to Bazel from Maven or Gradle - Riga Dev DaysHow to successfully migrate to Bazel from Maven or Gradle - Riga Dev Days
How to successfully migrate to Bazel from Maven or Gradle - Riga Dev DaysNatan Silnitsky
 
Node.js Build, Deploy and Scale Webinar
Node.js Build, Deploy and Scale WebinarNode.js Build, Deploy and Scale Webinar
Node.js Build, Deploy and Scale Webinarjguerrero999
 
Jenkins 101: Getting Started
Jenkins 101: Getting StartedJenkins 101: Getting Started
Jenkins 101: Getting StartedR Geoffrey Avery
 
Genymotion with Jenkins
Genymotion with JenkinsGenymotion with Jenkins
Genymotion with JenkinsVishal Nayak
 
Nginx维护手册
Nginx维护手册Nginx维护手册
Nginx维护手册Lei Yang
 
ДМИТРО БУДИМ «Mobile Automation Infrastructure from scratch» Online QADay 202...
ДМИТРО БУДИМ «Mobile Automation Infrastructure from scratch» Online QADay 202...ДМИТРО БУДИМ «Mobile Automation Infrastructure from scratch» Online QADay 202...
ДМИТРО БУДИМ «Mobile Automation Infrastructure from scratch» Online QADay 202...GoQA
 
Haibu: dev deployment is fast and easy again
Haibu: dev deployment is fast and easy againHaibu: dev deployment is fast and easy again
Haibu: dev deployment is fast and easy againFrank Rousseau
 
Developer mode on, czyli słów kilka o rbenv, rvm i ruby-ng
Developer mode on, czyli słów kilka o rbenv, rvm i ruby-ng Developer mode on, czyli słów kilka o rbenv, rvm i ruby-ng
Developer mode on, czyli słów kilka o rbenv, rvm i ruby-ng The Software House
 
Евгений Жарков "React Native: Hurdle Race"
Евгений Жарков "React Native: Hurdle Race"Евгений Жарков "React Native: Hurdle Race"
Евгений Жарков "React Native: Hurdle Race"Fwdays
 
Hacking Jenkins
Hacking JenkinsHacking Jenkins
Hacking JenkinsMiro Cupak
 
GitHub Actions for 5 minutes
GitHub Actions for 5 minutesGitHub Actions for 5 minutes
GitHub Actions for 5 minutesSvetlin Nakov
 
Delivery Pipeline for Windows Machines
Delivery Pipeline for Windows MachinesDelivery Pipeline for Windows Machines
Delivery Pipeline for Windows MachinesDmitry Buzdin
 
[English][Test Girls] Zero to Hero: Start Test automation with Cypress
[English][Test Girls] Zero to Hero: Start Test automation with Cypress[English][Test Girls] Zero to Hero: Start Test automation with Cypress
[English][Test Girls] Zero to Hero: Start Test automation with CypressTest Girls
 
How to Build & Deploy a HelloWorld API function using Java on OpenShift in...
How to Build & Deploy a HelloWorld API function using Java on OpenShift in...How to Build & Deploy a HelloWorld API function using Java on OpenShift in...
How to Build & Deploy a HelloWorld API function using Java on OpenShift in...Jan Vosecky
 
"Wix Serverless from inside", Mykola Borozdin
"Wix Serverless from inside", Mykola Borozdin"Wix Serverless from inside", Mykola Borozdin
"Wix Serverless from inside", Mykola BorozdinFwdays
 
Jenkins and rails app - Le Dinh Vu
Jenkins and rails app - Le Dinh VuJenkins and rails app - Le Dinh Vu
Jenkins and rails app - Le Dinh VuFramgia Vietnam
 
Bamboo Hands on training 2016
Bamboo Hands on training 2016Bamboo Hands on training 2016
Bamboo Hands on training 2016Takahiro Yamaki
 
Rise of the Machines - Automate your Development
Rise of the Machines - Automate your DevelopmentRise of the Machines - Automate your Development
Rise of the Machines - Automate your DevelopmentSven Peters
 
Selenium Grid & Docker - budowa środowiska do testów przeglądarkowych
Selenium Grid & Docker - budowa środowiska do testów przeglądarkowychSelenium Grid & Docker - budowa środowiska do testów przeglądarkowych
Selenium Grid & Docker - budowa środowiska do testów przeglądarkowychŁukasz Rosłonek
 

Tendances (20)

How to successfully migrate to Bazel from Maven or Gradle - Riga Dev Days
How to successfully migrate to Bazel from Maven or Gradle - Riga Dev DaysHow to successfully migrate to Bazel from Maven or Gradle - Riga Dev Days
How to successfully migrate to Bazel from Maven or Gradle - Riga Dev Days
 
Node.js Build, Deploy and Scale Webinar
Node.js Build, Deploy and Scale WebinarNode.js Build, Deploy and Scale Webinar
Node.js Build, Deploy and Scale Webinar
 
Jenkins 101: Getting Started
Jenkins 101: Getting StartedJenkins 101: Getting Started
Jenkins 101: Getting Started
 
Genymotion with Jenkins
Genymotion with JenkinsGenymotion with Jenkins
Genymotion with Jenkins
 
Nginx维护手册
Nginx维护手册Nginx维护手册
Nginx维护手册
 
ДМИТРО БУДИМ «Mobile Automation Infrastructure from scratch» Online QADay 202...
ДМИТРО БУДИМ «Mobile Automation Infrastructure from scratch» Online QADay 202...ДМИТРО БУДИМ «Mobile Automation Infrastructure from scratch» Online QADay 202...
ДМИТРО БУДИМ «Mobile Automation Infrastructure from scratch» Online QADay 202...
 
Haibu: dev deployment is fast and easy again
Haibu: dev deployment is fast and easy againHaibu: dev deployment is fast and easy again
Haibu: dev deployment is fast and easy again
 
Developer mode on, czyli słów kilka o rbenv, rvm i ruby-ng
Developer mode on, czyli słów kilka o rbenv, rvm i ruby-ng Developer mode on, czyli słów kilka o rbenv, rvm i ruby-ng
Developer mode on, czyli słów kilka o rbenv, rvm i ruby-ng
 
Евгений Жарков "React Native: Hurdle Race"
Евгений Жарков "React Native: Hurdle Race"Евгений Жарков "React Native: Hurdle Race"
Евгений Жарков "React Native: Hurdle Race"
 
Hacking Jenkins
Hacking JenkinsHacking Jenkins
Hacking Jenkins
 
GitHub Actions for 5 minutes
GitHub Actions for 5 minutesGitHub Actions for 5 minutes
GitHub Actions for 5 minutes
 
Delivery Pipeline for Windows Machines
Delivery Pipeline for Windows MachinesDelivery Pipeline for Windows Machines
Delivery Pipeline for Windows Machines
 
[English][Test Girls] Zero to Hero: Start Test automation with Cypress
[English][Test Girls] Zero to Hero: Start Test automation with Cypress[English][Test Girls] Zero to Hero: Start Test automation with Cypress
[English][Test Girls] Zero to Hero: Start Test automation with Cypress
 
How to Build & Deploy a HelloWorld API function using Java on OpenShift in...
How to Build & Deploy a HelloWorld API function using Java on OpenShift in...How to Build & Deploy a HelloWorld API function using Java on OpenShift in...
How to Build & Deploy a HelloWorld API function using Java on OpenShift in...
 
"Wix Serverless from inside", Mykola Borozdin
"Wix Serverless from inside", Mykola Borozdin"Wix Serverless from inside", Mykola Borozdin
"Wix Serverless from inside", Mykola Borozdin
 
Observability
ObservabilityObservability
Observability
 
Jenkins and rails app - Le Dinh Vu
Jenkins and rails app - Le Dinh VuJenkins and rails app - Le Dinh Vu
Jenkins and rails app - Le Dinh Vu
 
Bamboo Hands on training 2016
Bamboo Hands on training 2016Bamboo Hands on training 2016
Bamboo Hands on training 2016
 
Rise of the Machines - Automate your Development
Rise of the Machines - Automate your DevelopmentRise of the Machines - Automate your Development
Rise of the Machines - Automate your Development
 
Selenium Grid & Docker - budowa środowiska do testów przeglądarkowych
Selenium Grid & Docker - budowa środowiska do testów przeglądarkowychSelenium Grid & Docker - budowa środowiska do testów przeglądarkowych
Selenium Grid & Docker - budowa środowiska do testów przeglądarkowych
 

Similaire à Jsconf asia pm2

Alfresco Development Framework Basic
Alfresco Development Framework BasicAlfresco Development Framework Basic
Alfresco Development Framework BasicMario Romano
 
Im-A-Hacker-Get-Me-Out-Of-Here-Breaking-Network-Segregation-Using-Esoteric-Co...
Im-A-Hacker-Get-Me-Out-Of-Here-Breaking-Network-Segregation-Using-Esoteric-Co...Im-A-Hacker-Get-Me-Out-Of-Here-Breaking-Network-Segregation-Using-Esoteric-Co...
Im-A-Hacker-Get-Me-Out-Of-Here-Breaking-Network-Segregation-Using-Esoteric-Co...YuChianWu
 
PAC 2019 virtual Bruno Audoux
PAC 2019 virtual Bruno Audoux PAC 2019 virtual Bruno Audoux
PAC 2019 virtual Bruno Audoux Neotys
 
Why Kubernetes? Cloud Native and Developer Experience at Zalando - OWL Tech &...
Why Kubernetes? Cloud Native and Developer Experience at Zalando - OWL Tech &...Why Kubernetes? Cloud Native and Developer Experience at Zalando - OWL Tech &...
Why Kubernetes? Cloud Native and Developer Experience at Zalando - OWL Tech &...Henning Jacobs
 
6 tips for improving ruby performance
6 tips for improving ruby performance6 tips for improving ruby performance
6 tips for improving ruby performanceEngine Yard
 
How to build streaming data pipelines with Akka Streams, Flink, and Spark usi...
How to build streaming data pipelines with Akka Streams, Flink, and Spark usi...How to build streaming data pipelines with Akka Streams, Flink, and Spark usi...
How to build streaming data pipelines with Akka Streams, Flink, and Spark usi...Lightbend
 
IBM Cloud University: Build, Deploy and Scale Node.js Microservices
IBM Cloud University: Build, Deploy and Scale Node.js MicroservicesIBM Cloud University: Build, Deploy and Scale Node.js Microservices
IBM Cloud University: Build, Deploy and Scale Node.js MicroservicesChris Bailey
 
App engine devfest_mexico_10
App engine devfest_mexico_10App engine devfest_mexico_10
App engine devfest_mexico_10Chris Schalk
 
CI/CD and TDD in deploying kamailio
CI/CD and TDD in deploying kamailioCI/CD and TDD in deploying kamailio
CI/CD and TDD in deploying kamailioAleksandar Sosic
 
What is going on - Application diagnostics on Azure - TechDays Finland
What is going on - Application diagnostics on Azure - TechDays FinlandWhat is going on - Application diagnostics on Azure - TechDays Finland
What is going on - Application diagnostics on Azure - TechDays FinlandMaarten Balliauw
 
PyCon AU 2012 - Debugging Live Python Web Applications
PyCon AU 2012 - Debugging Live Python Web ApplicationsPyCon AU 2012 - Debugging Live Python Web Applications
PyCon AU 2012 - Debugging Live Python Web ApplicationsGraham Dumpleton
 
Running MongoDB Enterprise on Kubernetes
Running MongoDB Enterprise on KubernetesRunning MongoDB Enterprise on Kubernetes
Running MongoDB Enterprise on KubernetesAriel Jatib
 
IBM Monitoring and Diagnostic Tools - GCMV 2.8
IBM Monitoring and Diagnostic Tools - GCMV 2.8IBM Monitoring and Diagnostic Tools - GCMV 2.8
IBM Monitoring and Diagnostic Tools - GCMV 2.8Chris Bailey
 
Docker based Architecture by Denys Serdiuk
Docker based Architecture by Denys SerdiukDocker based Architecture by Denys Serdiuk
Docker based Architecture by Denys SerdiukLohika_Odessa_TechTalks
 
OpenStack API's and WSGI
OpenStack API's and WSGIOpenStack API's and WSGI
OpenStack API's and WSGIMike Pittaro
 

Similaire à Jsconf asia pm2 (20)

Alfresco Development Framework Basic
Alfresco Development Framework BasicAlfresco Development Framework Basic
Alfresco Development Framework Basic
 
Iac d.damyanov 4.pptx
Iac d.damyanov 4.pptxIac d.damyanov 4.pptx
Iac d.damyanov 4.pptx
 
Im-A-Hacker-Get-Me-Out-Of-Here-Breaking-Network-Segregation-Using-Esoteric-Co...
Im-A-Hacker-Get-Me-Out-Of-Here-Breaking-Network-Segregation-Using-Esoteric-Co...Im-A-Hacker-Get-Me-Out-Of-Here-Breaking-Network-Segregation-Using-Esoteric-Co...
Im-A-Hacker-Get-Me-Out-Of-Here-Breaking-Network-Segregation-Using-Esoteric-Co...
 
PAC 2019 virtual Bruno Audoux
PAC 2019 virtual Bruno Audoux PAC 2019 virtual Bruno Audoux
PAC 2019 virtual Bruno Audoux
 
Cloud APIs Overview Tucker
Cloud APIs Overview   TuckerCloud APIs Overview   Tucker
Cloud APIs Overview Tucker
 
Why Kubernetes? Cloud Native and Developer Experience at Zalando - OWL Tech &...
Why Kubernetes? Cloud Native and Developer Experience at Zalando - OWL Tech &...Why Kubernetes? Cloud Native and Developer Experience at Zalando - OWL Tech &...
Why Kubernetes? Cloud Native and Developer Experience at Zalando - OWL Tech &...
 
Docker Monitoring Webinar
Docker Monitoring  WebinarDocker Monitoring  Webinar
Docker Monitoring Webinar
 
6 tips for improving ruby performance
6 tips for improving ruby performance6 tips for improving ruby performance
6 tips for improving ruby performance
 
How to build streaming data pipelines with Akka Streams, Flink, and Spark usi...
How to build streaming data pipelines with Akka Streams, Flink, and Spark usi...How to build streaming data pipelines with Akka Streams, Flink, and Spark usi...
How to build streaming data pipelines with Akka Streams, Flink, and Spark usi...
 
Angular2 inter3
Angular2 inter3Angular2 inter3
Angular2 inter3
 
IBM Cloud University: Build, Deploy and Scale Node.js Microservices
IBM Cloud University: Build, Deploy and Scale Node.js MicroservicesIBM Cloud University: Build, Deploy and Scale Node.js Microservices
IBM Cloud University: Build, Deploy and Scale Node.js Microservices
 
Docker In Bank Unrated
Docker In Bank UnratedDocker In Bank Unrated
Docker In Bank Unrated
 
App engine devfest_mexico_10
App engine devfest_mexico_10App engine devfest_mexico_10
App engine devfest_mexico_10
 
CI/CD and TDD in deploying kamailio
CI/CD and TDD in deploying kamailioCI/CD and TDD in deploying kamailio
CI/CD and TDD in deploying kamailio
 
What is going on - Application diagnostics on Azure - TechDays Finland
What is going on - Application diagnostics on Azure - TechDays FinlandWhat is going on - Application diagnostics on Azure - TechDays Finland
What is going on - Application diagnostics on Azure - TechDays Finland
 
PyCon AU 2012 - Debugging Live Python Web Applications
PyCon AU 2012 - Debugging Live Python Web ApplicationsPyCon AU 2012 - Debugging Live Python Web Applications
PyCon AU 2012 - Debugging Live Python Web Applications
 
Running MongoDB Enterprise on Kubernetes
Running MongoDB Enterprise on KubernetesRunning MongoDB Enterprise on Kubernetes
Running MongoDB Enterprise on Kubernetes
 
IBM Monitoring and Diagnostic Tools - GCMV 2.8
IBM Monitoring and Diagnostic Tools - GCMV 2.8IBM Monitoring and Diagnostic Tools - GCMV 2.8
IBM Monitoring and Diagnostic Tools - GCMV 2.8
 
Docker based Architecture by Denys Serdiuk
Docker based Architecture by Denys SerdiukDocker based Architecture by Denys Serdiuk
Docker based Architecture by Denys Serdiuk
 
OpenStack API's and WSGI
OpenStack API's and WSGIOpenStack API's and WSGI
OpenStack API's and WSGI
 

Dernier

(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...ranjana rawat
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...ranjana rawat
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )Tsuyoshi Horigome
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130Suhani Kapoor
 
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
UNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its PerformanceUNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its Performancesivaprakash250
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxAsutosh Ranjan
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...Soham Mondal
 
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSMANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSSIVASHANKAR N
 
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Christo Ananth
 
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingUNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingrknatarajan
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Christo Ananth
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).pptssuser5c9d4b1
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingrakeshbaidya232001
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVRajaP95
 
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSKurinjimalarL3
 

Dernier (20)

(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
 
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
UNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its PerformanceUNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its Performance
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptx
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
 
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSMANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
 
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
 
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingUNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
 
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writing
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
 
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
 

Jsconf asia pm2

  • 1.
  • 2. • CEO & Founder at • Author of • Full Stack Javascript developer • Technologist
  • 3. My app is ready, now what?
  • 4. Deploying to production is complex • Oh noes why my app only use 10% of my server CPUs? • Oh noes which app is leaking memory? • Why the server went out of memory? • Oh noes my app crashed! • Where are my damn logs? • How do I organize my micro service app? • …. …. …. ….
  • 5.
  • 6. Production application toolbox with a Built-in load balancer that Guarantees Uptime and help you manage your processes
  • 7. App #1 App #2 App #3 App #4 App #1 App #3 App #4 CL1 CL2 CL3 CL4 Disorganized application & workflow Structured application & workflow To Before After
  • 8. App #1 App #3 App #4 UsabilityCPU Memory Log DeploymentModules CL1 CL2 CL3 CL4 Ressources management and optimization Easier software management Extend capabilities
  • 9. PM2: Some figures • 10.000+ stars on GitHub • 2.000.000+ downloads • 2500+ commits • 120+ contributors • 750+ tests
  • 11.
  • 13. Installing PM2 $ npm install pm2 -g Source code: https://github.com/Unitech/pm2 Documentation: http://pm2.keymetrics.io
  • 14. Setup PM2 No setup required! But… $ pm2 completion install Enabling autocompletion: $ pm2 startup Respawning PM2 on server boot: http://pm2.keymetrics.io/docs/usage/quick-start/
  • 16. Launching a Node.js application $ pm2 start app.js Put application in background Handle logs Monitor Auto respawn application
  • 17. Launching any kind of application $ pm2 start app.py —interpreter="python3" $ pm2 start script.sh Starting a bash script: Starting a Python app & set interpreter http://pm2.keymetrics.io/docs/usage/process-management/
  • 18. Acting on processes $ pm2 delete <app-name|app-id|'all'> $ pm2 restart <app-name|app-id|'all'> Restart: Delete: $ pm2 stop <app-name|app-id|'all'> Stop: http://pm2.keymetrics.io/docs/usage/process-management/
  • 21. Why using the cluster mode? Intel® Xeon® Processor E5-1410 v2 - 8 cores
  • 22. Starting an application cluster mode $ pm2 start app.js -i <instances> http://pm2.keymetrics.io/docs/usage/cluster-mode/
  • 23. Managing clustered applications $ pm2 gracefulReload <app-name|'all'> $ pm2 reload <app-name|'all'> Reload without downtime: Graceful Reload (send signal to process): $ pm2 scale <app-name> <instances> Scale up/down process number: http://pm2.keymetrics.io/docs/usage/cluster-mode/
  • 25. $ pm2 list Listing processes
  • 26. $ pm2 monit Monitoring CPU & Memory
  • 27. $ pm2 show <app-name|id> More informations
  • 28. Inspecting logs $ pm2 flush $ pm2 logs [app-name] Display logs in realtime: Flushing logs: $ pm2 reloadLogs Reloading logs (logrotate): http://pm2.keymetrics.io/docs/usage/log-management/
  • 30. Starting your micro service app… $ DEBUG=“*” NODE_ENV="production" pm2 start app-1.js — name “API” -i 8 —watch —max-memory-restart=“300M” — -a 23 $ DEBUG=“app2:*” NODE_ENV=“production" pm2 start app-2.js —name “WORKER" —watch — -a prod $ DEBUG=“app3:*” NODE_ENV=“production" pm2 start app-3.js —name “BDD" —watch — -a malo
  • 31. UGLY
  • 32. Solution: JSON declaration Application 1 (API) Application 2 (Worker) Application 3 (Crawler) ecosystem.json
  • 33. Using the JSON declaration $ pm2 restart ecosystem.json $ pm2 start ecosystem.json Start: Restart: $ pm2 stop <app-name|app-id|'all'> Stop: http://pm2.keymetrics.io/docs/usage/application-declaration/
  • 35. Extending the previous JSONecosystem.json Production env Staging env Multi host
  • 36. Deployment commands $ pm2 deploy ecosystem.json production $ pm2 deploy ecosystem.json production setup Setup remote server: Update remote application: Revert to the n-th deployment: $ pm2 deploy ecosystem.json production revert [n] http://pm2.keymetrics.io/docs/usage/deployment/
  • 38. What is a module? An app that extend PM2 capabilities or A worker process providing an API or A totally independant software
  • 39. Installing a module $ pm2 install <module-name> It gets the module from NPM then Start it and Keep it alive forever http://docs.keymetrics.io/docs/usage/building-module/
  • 40. Managing modules $ pm2 uninstall <module-name> $ pm2 install <module-name> Install a module: Uninstall: $ pm2 set <module-name>:<attr> <value> Set configuration option: http://docs.keymetrics.io/docs/usage/building-module/
  • 42. Module #1: pm2-logrotate $ pm2 install pm2-logrotate Automatically rotate all logs of applications managed by pm2 https://github.com/pm2-hive/pm2-logrotate
  • 43. Module #2: pm2-webshell $ pm2 install pm2-webshell Expose a fully capable terminal in your browser https://github.com/pm2-hive/pm2-webshell
  • 44. Module #2: pm2-webshell Termcaps capable Backed by TTY.js HTTPS support Pass/User configurable Port
  • 47. Writing your own module $ pm2 module:generate sample-module Create a sample module: Documentation: Google -> pm2 module system Official modules repositories: http://github.com/pm2-hive/