# Process manager
Process managers allow you to keep your Strapi application running and to reload it without downtime. The following documentation uses the PM2 (opens new window) process manager and describes:
- installing PM2,
- starting Strapi using a
- starting Strapi using the
- starting and managing Strapi using an
The appropriate procedure for starting PM2 depends on the hosting provider and your application configuration.
# Install PM2
Install PM2 globally:
# Start PM2 with a
The basic usage to start an application with PM2 is to run a command such as
pm2 start server.js. To configure and run your application:
server.jsfile at the application root.
Add the following code snippet to the
Start the server by running
pm2 start server.jsin the project root directory.
TypeScript projects require additional code in the
server.js file to identify the correct directory. See the previous TypeScript code example or the TypeScript documentation for additional details.
# Start PM2 with the
To start PM2 and your application from a terminal you should start PM2 and pass the application name and start command as arguments:
# Start and configure PM2 with a
A PM2 configuration file allows you to save the information necessary to start your server properly at any time. This is commonly used for cloud hosting providers, where you might not have access to a terminal window to start the server. To use a configuration file:
pm2 initat the application root to create an
ecosystem.config.jsfile content with the following code example:
pm2 start ecosystem.config.jsto start the PM2 process.
ecosystem.config.js code example is the minimum configuration. The PM2 ecosystem file documentation (opens new window) provides all of the configuration options.