← Back to Node.js Course | Chapter 10: Deployment & Best Practices | Lesson 3 of 7

PM2 के Basics

PM2 आपकी Node app को चालू रखता है, crash होने पर इसे restart करता है, और कई copies चला सकता है।

In this page:

  1. PM2 Basics
Syntax
javascript
pm2 start app.js
pm2 list
pm2 restart app
pm2 stop app

PM2 Basics

PM2 एक process manager है। pm2 start app.js app को background में चलाता है, pm2 list status दिखाता है, pm2 logs output stream करता है, और pm2 restart changes apply करता है। Cluster mode प्रति CPU core एक process चलाता है और एक ecosystem file settings record करता है।

Note: reboot के बाद apps restart करने के लिए pm2 startup और pm2 save इस्तेमाल करें।

उदाहरण: PM2 basics

bash
$ npm install -g pm2
$ pm2 start app.js -i max --name api
$ pm2 list
$ pm2 logs api
$ pm2 save && pm2 startup

⚠️ Run this in your own terminal or Node.js environment.

Related Topics
{# common_mistakes/chapter_summary/browser_support: on Hindi pages the view already swaps in the hi_ translation fields (or blanks these out if untranslated), so this renders correctly for both languages without a lang_code check here. #}
आम गलतियां
  1. एक server पर directly node चलाना
  2. process list save न करना
  3. log rotation ignore करना
चैप्टर सारांश
  • PM2 crashed apps restart करता है
  • start, list, logs, restart jaise commands मिलते हैं
  • Cluster mode सारे cores इस्तेमाल करता है
  • Ecosystem files config store करती हैं
🔒

Chapter Quiz — Complete all 7 topics to unlock

0/7 topics done

Complete these topics first:

Login to run this code

C/C++/Java/PHP execution requires a free account. Your code is saved — you'll land right back in the editor after logging in.