Repository navigation
Support pm2 deployment and clustering
This release of Bedrock adds support for the following:
- Deploying the app via pm2
- Adding Cluster support via the express-cluster module
pm2 Deployment
Lately, I've preferred to use pm2 over forever when it comes to deploying a server to production. pm2 has more features and a better API. One of the things I especially like about it is the support it has for JSON App Declarations. Basically, you can create a JSON file (ex: server.json) and then start an instance of the server by running:
pm2 start server.json
pm2 will pick up all the configuration parameters from the JSON file. You don't have to pass it in via the command line. This makes it easy to script pm2 deploys for multiple apps without the script needing to know about app-specific configuration parameters.
Bedrock now has a server.json file which you should change to match your app. If you don't want to use pm2, simply delete that file.
Cluster support
Cluster lets you spawn multiple instances of your app based on the number of CPUs available on the box that the app is being deployed on. It is a simple way to increase the performance of your app. Bedrock now has cluster support. If you want to enable it, go into server.js and do the following:
Comment out this line:
setupServer();
And uncomment this line:
cluster(setupServer());
Happy coding!