SlideShare a Scribd company logo
• 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

More Related Content

What's hot

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
Natan 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 Webinar
jguerrero999
 
Jenkins 101: Getting Started
Jenkins 101: Getting StartedJenkins 101: Getting Started
Jenkins 101: Getting Started
R Geoffrey Avery
 
Genymotion with Jenkins
Genymotion with JenkinsGenymotion with Jenkins
Genymotion with Jenkins
Vishal 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...
QADay
 
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
Frank 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 Jenkins
Miro Cupak
 
GitHub Actions for 5 minutes
GitHub Actions for 5 minutesGitHub Actions for 5 minutes
GitHub Actions for 5 minutes
Svetlin Nakov
 
Delivery Pipeline for Windows Machines
Delivery Pipeline for Windows MachinesDelivery Pipeline for Windows Machines
Delivery Pipeline for Windows Machines
Dmitry 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 Cypress
Test 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 Borozdin
Fwdays
 
Observability
ObservabilityObservability
Observability
Diego Pacheco
 
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
Framgia Vietnam
 
Bamboo Hands on training 2016
Bamboo Hands on training 2016Bamboo Hands on training 2016
Bamboo Hands on training 2016
Takahiro 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 Development
Sven 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
 

What's hot (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
 

Similar to Jsconf asia pm2

Alfresco Development Framework Basic
Alfresco Development Framework BasicAlfresco Development Framework Basic
Alfresco Development Framework Basic
Mario Romano
 
Iac d.damyanov 4.pptx
Iac d.damyanov 4.pptxIac d.damyanov 4.pptx
Iac d.damyanov 4.pptx
Dimitar Damyanov
 
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
 
Cloud APIs Overview Tucker
Cloud APIs Overview   TuckerCloud APIs Overview   Tucker
Cloud APIs Overview Tucker
Infrastructure 2.0
 
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
 
Docker Monitoring Webinar
Docker Monitoring  WebinarDocker Monitoring  Webinar
Docker Monitoring Webinar
Sematext Group, Inc.
 
6 tips for improving ruby performance
6 tips for improving ruby performance6 tips for improving ruby performance
6 tips for improving ruby performance
Engine 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
 
Angular2 inter3
Angular2 inter3Angular2 inter3
Angular2 inter3
Oswald Campesato
 
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
Chris Bailey
 
Docker In Bank Unrated
Docker In Bank UnratedDocker In Bank Unrated
Docker In Bank Unrated
Aleksandr Tarasov
 
App engine devfest_mexico_10
App engine devfest_mexico_10App engine devfest_mexico_10
App engine devfest_mexico_10
Chris 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 kamailio
Aleksandar 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 Finland
Maarten 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 Applications
Graham Dumpleton
 
Running MongoDB Enterprise on Kubernetes
Running MongoDB Enterprise on KubernetesRunning MongoDB Enterprise on Kubernetes
Running MongoDB Enterprise on Kubernetes
Ariel 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.8
Chris Bailey
 
Docker based Architecture by Denys Serdiuk
Docker based Architecture by Denys SerdiukDocker based Architecture by Denys Serdiuk
Docker based Architecture by Denys Serdiuk
Lohika_Odessa_TechTalks
 
OpenStack API's and WSGI
OpenStack API's and WSGIOpenStack API's and WSGI
OpenStack API's and WSGI
Mike Pittaro
 

Similar to 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
 

Recently uploaded

CompEx~Manual~1210 (2).pdf COMPEX GAS AND VAPOURS
CompEx~Manual~1210 (2).pdf COMPEX GAS AND VAPOURSCompEx~Manual~1210 (2).pdf COMPEX GAS AND VAPOURS
CompEx~Manual~1210 (2).pdf COMPEX GAS AND VAPOURS
RamonNovais6
 
artificial intelligence and data science contents.pptx
artificial intelligence and data science contents.pptxartificial intelligence and data science contents.pptx
artificial intelligence and data science contents.pptx
GauravCar
 
Applications of artificial Intelligence in Mechanical Engineering.pdf
Applications of artificial Intelligence in Mechanical Engineering.pdfApplications of artificial Intelligence in Mechanical Engineering.pdf
Applications of artificial Intelligence in Mechanical Engineering.pdf
Atif Razi
 
CEC 352 - SATELLITE COMMUNICATION UNIT 1
CEC 352 - SATELLITE COMMUNICATION UNIT 1CEC 352 - SATELLITE COMMUNICATION UNIT 1
CEC 352 - SATELLITE COMMUNICATION UNIT 1
PKavitha10
 
Engineering Drawings Lecture Detail Drawings 2014.pdf
Engineering Drawings Lecture Detail Drawings 2014.pdfEngineering Drawings Lecture Detail Drawings 2014.pdf
Engineering Drawings Lecture Detail Drawings 2014.pdf
abbyasa1014
 
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
insn4465
 
Welding Metallurgy Ferrous Materials.pdf
Welding Metallurgy Ferrous Materials.pdfWelding Metallurgy Ferrous Materials.pdf
Welding Metallurgy Ferrous Materials.pdf
AjmalKhan50578
 
BRAIN TUMOR DETECTION for seminar ppt.pdf
BRAIN TUMOR DETECTION for seminar ppt.pdfBRAIN TUMOR DETECTION for seminar ppt.pdf
BRAIN TUMOR DETECTION for seminar ppt.pdf
LAXMAREDDY22
 
LLM Fine Tuning with QLoRA Cassandra Lunch 4, presented by Anant
LLM Fine Tuning with QLoRA Cassandra Lunch 4, presented by AnantLLM Fine Tuning with QLoRA Cassandra Lunch 4, presented by Anant
LLM Fine Tuning with QLoRA Cassandra Lunch 4, presented by Anant
Anant Corporation
 
Rainfall intensity duration frequency curve statistical analysis and modeling...
Rainfall intensity duration frequency curve statistical analysis and modeling...Rainfall intensity duration frequency curve statistical analysis and modeling...
Rainfall intensity duration frequency curve statistical analysis and modeling...
bijceesjournal
 
官方认证美国密歇根州立大学毕业证学位证书原版一模一样
官方认证美国密歇根州立大学毕业证学位证书原版一模一样官方认证美国密歇根州立大学毕业证学位证书原版一模一样
官方认证美国密歇根州立大学毕业证学位证书原版一模一样
171ticu
 
学校原版美国波士顿大学毕业证学历学位证书原版一模一样
学校原版美国波士顿大学毕业证学历学位证书原版一模一样学校原版美国波士顿大学毕业证学历学位证书原版一模一样
学校原版美国波士顿大学毕业证学历学位证书原版一模一样
171ticu
 
Redefining brain tumor segmentation: a cutting-edge convolutional neural netw...
Redefining brain tumor segmentation: a cutting-edge convolutional neural netw...Redefining brain tumor segmentation: a cutting-edge convolutional neural netw...
Redefining brain tumor segmentation: a cutting-edge convolutional neural netw...
IJECEIAES
 
Computational Engineering IITH Presentation
Computational Engineering IITH PresentationComputational Engineering IITH Presentation
Computational Engineering IITH Presentation
co23btech11018
 
Material for memory and display system h
Material for memory and display system hMaterial for memory and display system h
Material for memory and display system h
gowrishankartb2005
 
An improved modulation technique suitable for a three level flying capacitor ...
An improved modulation technique suitable for a three level flying capacitor ...An improved modulation technique suitable for a three level flying capacitor ...
An improved modulation technique suitable for a three level flying capacitor ...
IJECEIAES
 
Data Driven Maintenance | UReason Webinar
Data Driven Maintenance | UReason WebinarData Driven Maintenance | UReason Webinar
Data Driven Maintenance | UReason Webinar
UReason
 
Embedded machine learning-based road conditions and driving behavior monitoring
Embedded machine learning-based road conditions and driving behavior monitoringEmbedded machine learning-based road conditions and driving behavior monitoring
Embedded machine learning-based road conditions and driving behavior monitoring
IJECEIAES
 
22CYT12-Unit-V-E Waste and its Management.ppt
22CYT12-Unit-V-E Waste and its Management.ppt22CYT12-Unit-V-E Waste and its Management.ppt
22CYT12-Unit-V-E Waste and its Management.ppt
KrishnaveniKrishnara1
 
4. Mosca vol I -Fisica-Tipler-5ta-Edicion-Vol-1.pdf
4. Mosca vol I -Fisica-Tipler-5ta-Edicion-Vol-1.pdf4. Mosca vol I -Fisica-Tipler-5ta-Edicion-Vol-1.pdf
4. Mosca vol I -Fisica-Tipler-5ta-Edicion-Vol-1.pdf
Gino153088
 

Recently uploaded (20)

CompEx~Manual~1210 (2).pdf COMPEX GAS AND VAPOURS
CompEx~Manual~1210 (2).pdf COMPEX GAS AND VAPOURSCompEx~Manual~1210 (2).pdf COMPEX GAS AND VAPOURS
CompEx~Manual~1210 (2).pdf COMPEX GAS AND VAPOURS
 
artificial intelligence and data science contents.pptx
artificial intelligence and data science contents.pptxartificial intelligence and data science contents.pptx
artificial intelligence and data science contents.pptx
 
Applications of artificial Intelligence in Mechanical Engineering.pdf
Applications of artificial Intelligence in Mechanical Engineering.pdfApplications of artificial Intelligence in Mechanical Engineering.pdf
Applications of artificial Intelligence in Mechanical Engineering.pdf
 
CEC 352 - SATELLITE COMMUNICATION UNIT 1
CEC 352 - SATELLITE COMMUNICATION UNIT 1CEC 352 - SATELLITE COMMUNICATION UNIT 1
CEC 352 - SATELLITE COMMUNICATION UNIT 1
 
Engineering Drawings Lecture Detail Drawings 2014.pdf
Engineering Drawings Lecture Detail Drawings 2014.pdfEngineering Drawings Lecture Detail Drawings 2014.pdf
Engineering Drawings Lecture Detail Drawings 2014.pdf
 
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
 
Welding Metallurgy Ferrous Materials.pdf
Welding Metallurgy Ferrous Materials.pdfWelding Metallurgy Ferrous Materials.pdf
Welding Metallurgy Ferrous Materials.pdf
 
BRAIN TUMOR DETECTION for seminar ppt.pdf
BRAIN TUMOR DETECTION for seminar ppt.pdfBRAIN TUMOR DETECTION for seminar ppt.pdf
BRAIN TUMOR DETECTION for seminar ppt.pdf
 
LLM Fine Tuning with QLoRA Cassandra Lunch 4, presented by Anant
LLM Fine Tuning with QLoRA Cassandra Lunch 4, presented by AnantLLM Fine Tuning with QLoRA Cassandra Lunch 4, presented by Anant
LLM Fine Tuning with QLoRA Cassandra Lunch 4, presented by Anant
 
Rainfall intensity duration frequency curve statistical analysis and modeling...
Rainfall intensity duration frequency curve statistical analysis and modeling...Rainfall intensity duration frequency curve statistical analysis and modeling...
Rainfall intensity duration frequency curve statistical analysis and modeling...
 
官方认证美国密歇根州立大学毕业证学位证书原版一模一样
官方认证美国密歇根州立大学毕业证学位证书原版一模一样官方认证美国密歇根州立大学毕业证学位证书原版一模一样
官方认证美国密歇根州立大学毕业证学位证书原版一模一样
 
学校原版美国波士顿大学毕业证学历学位证书原版一模一样
学校原版美国波士顿大学毕业证学历学位证书原版一模一样学校原版美国波士顿大学毕业证学历学位证书原版一模一样
学校原版美国波士顿大学毕业证学历学位证书原版一模一样
 
Redefining brain tumor segmentation: a cutting-edge convolutional neural netw...
Redefining brain tumor segmentation: a cutting-edge convolutional neural netw...Redefining brain tumor segmentation: a cutting-edge convolutional neural netw...
Redefining brain tumor segmentation: a cutting-edge convolutional neural netw...
 
Computational Engineering IITH Presentation
Computational Engineering IITH PresentationComputational Engineering IITH Presentation
Computational Engineering IITH Presentation
 
Material for memory and display system h
Material for memory and display system hMaterial for memory and display system h
Material for memory and display system h
 
An improved modulation technique suitable for a three level flying capacitor ...
An improved modulation technique suitable for a three level flying capacitor ...An improved modulation technique suitable for a three level flying capacitor ...
An improved modulation technique suitable for a three level flying capacitor ...
 
Data Driven Maintenance | UReason Webinar
Data Driven Maintenance | UReason WebinarData Driven Maintenance | UReason Webinar
Data Driven Maintenance | UReason Webinar
 
Embedded machine learning-based road conditions and driving behavior monitoring
Embedded machine learning-based road conditions and driving behavior monitoringEmbedded machine learning-based road conditions and driving behavior monitoring
Embedded machine learning-based road conditions and driving behavior monitoring
 
22CYT12-Unit-V-E Waste and its Management.ppt
22CYT12-Unit-V-E Waste and its Management.ppt22CYT12-Unit-V-E Waste and its Management.ppt
22CYT12-Unit-V-E Waste and its Management.ppt
 
4. Mosca vol I -Fisica-Tipler-5ta-Edicion-Vol-1.pdf
4. Mosca vol I -Fisica-Tipler-5ta-Edicion-Vol-1.pdf4. Mosca vol I -Fisica-Tipler-5ta-Edicion-Vol-1.pdf
4. Mosca vol I -Fisica-Tipler-5ta-Edicion-Vol-1.pdf
 

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/