A. The app crashed and PM2 is trying to restart it
B. The app is stopped but still listed in PM2 process list
C. The app is running and managed by PM2
D. The app is removed from PM2 process list
Solution
Step 1: Analyze each command effect
pm2 start app.js --name myapp starts and names the app. pm2 restart myapp restarts it. pm2 stop myapp stops it but keeps it listed. pm2 delete myapp removes it from PM2's list.
Step 2: Determine final state
After deletion, the app is no longer managed or listed by PM2.
Final Answer:
The app is removed from PM2 process list -> Option D
Quick Check:
Delete removes app from PM2 list [OK]
Hint: Delete removes app from PM2 list, stop just pauses it [OK]
Common Mistakes:
Confusing stop with delete
Assuming restart keeps app stopped
Thinking delete crashes the app
4. You run pm2 start app.js but the app crashes immediately. Which PM2 command helps you see the error logs to debug the issue?
medium
A. pm2 status
B. pm2 logs
C. pm2 restart
D. pm2 list
Solution
Step 1: Identify command to view logs
pm2 logs shows real-time logs including errors from apps managed by PM2.
Step 2: Compare other commands
pm2 status and pm2 list show process info but not detailed logs. pm2 restart restarts apps but doesn't show logs.
Final Answer:
pm2 logs -> Option B
Quick Check:
Logs show errors for debugging [OK]
Hint: Use 'pm2 logs' to see app errors instantly [OK]
Common Mistakes:
Using 'pm2 status' to find errors
Restarting app without checking logs
Confusing 'pm2 list' with logs
5. You want PM2 to automatically restart your app server.js whenever the file changes during development. Which command achieves this?
hard
A. pm2 start server.js --watch
B. pm2 start server.js --no-restart
C. pm2 start server.js --ignore-watch
D. pm2 start server.js --restart-delay 1000
Solution
Step 1: Understand PM2 watch option
The --watch flag tells PM2 to watch for file changes and restart the app automatically.
Step 2: Evaluate other options
--no-restart disables restarts, --ignore-watch disables watching, and --restart-delay adds delay but doesn't enable watching.
Final Answer:
pm2 start server.js --watch -> Option A
Quick Check:
Watch flag enables auto-restart on file changes [OK]
Hint: Use '--watch' to auto-restart on file changes [OK]
Common Mistakes:
Using --no-restart disables restarts
Ignoring watch disables file monitoring
Restart delay doesn't watch files
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.