Skip to main content
ProStack includes PM2 configuration for robust production deployment. PM2 is a daemon process manager that helps you manage and keep your application online 24/7.

What is PM2?

PM2 is a production process manager for Node.js applications. It allows you to:
  • Keep applications alive forever
  • Reload applications with zero downtime
  • Facilitate common system admin tasks
  • Manage application logging, monitoring, and clustering

PM2 Configuration

ProStack comes with a pre-configured ecosystem.config.js file in the root directory:

Configuration Options Explained

The ecosystem file configures the following options:

Installing PM2

Before using PM2, you need to install it globally on your server:

Deploying with PM2

To deploy your application with PM2:
  1. Build your Next.js application:
  1. Start the application with PM2:

Managing Your Application

View Application Status

This shows all running applications, their status, resource usage, and uptime.

View Application Logs

To view just errors:

Restart the Application

Stop the Application

Delete from PM2

PM2 Monitoring

PM2 provides a simple monitoring interface:
This command opens a dashboard showing real-time metrics about your application.

Setting Up PM2 to Start on System Boot

To ensure your application starts automatically when the server reboots:
Follow the instructions provided by the command to set up the startup script. Then save your current PM2 configuration:

PM2 Ecosystem File Extensions

You can extend the ecosystem file to support multiple environments or applications:

Next Steps

Docker Deployment

Alternative deployment option using Docker

Environment Variables

Configure your application for production