PM2 tips - uncommon ssh port, cluster_mode and deploy troubleshooting

Note: PM2 own code quality is bad and cluster_mode is not production ready. I would not recommend to use PM2, anywhere. You have been warned.

How to use a different ssh port for PM2

Since pm2-deploy directly forward the host string to ssh, you can simply use: "host": "HOSTNAME -p PORT" inside the configuration file.

How to use cluster_mode in PM2

Make your app instances listen on port 8000 and pm2 will load-balance any request on 8080 to your app instances.

Troubleshooting pm2 deploy

pm2-deploy outputs its log into /tmp/pm2-deploy.log so if you don't understand why pm2 deploy is not working, a tail -f /tmp/pm2-deploy.log might help.

[Book Review] Mastering JavaScript Design Patterns

Mastering JavaScript Design Patterns (MJDP) is another book Packt graciously sent me. This book is divided in two parts. The first part is about Gang Of Four (GoF) classical Design Patterns the other part is about other well know patterns.

TL;DR: Overall the book is good enough and will be perfect for developers with little experience in software development.

However be careful with the following points below:

  • UML diagrams are not descriptive as they should be, "memberName" should not be written multiple times as class attributes
  • The part where the author said that singleton could not be created in JavaScript in a OOP way is plain wrong
  • In the Functional Programming chapter, JavaScript examples could have been written better. Using a for loop instead of map (IE9+) is disappointing (to say the least!)
  • The MV* chapter does not follow the Separation of Concerns principle well enough
    • View initialization and rendering are done inside the constructor (they should not be)
    • Model attributes are too often manipulated inside the controller
    • State information is duplicated (e.g. IsValid in ValidationResult)
    • A dispose (or release) method is missing for clean life-cycle management
    • bind (IE9+) should be used instead of the old _this workaround
Made with on a hot august night.