Skip to content

Managing Processes

MaxixSVK edited this page Apr 11, 2026 · 1 revision

You already learned you can run npm run env to run all processes at once. This is a great way to get started, but you may want to run each process separately and handle crashes and automatic restarts.

We will use PM2

Install PM2

npm install pm2 -g

Start processes

  1. Navigate to the project directory
cd mDB/
  1. Start the processes
pm2 start src/index.js --name mdb-api
pm2 start src/webServer.js --name mdb-web
  1. Save the process list
pm2 save
  1. Start processes on system startup
pm2 startup

Restart processes

To restart the processes, you can use:

pm2 restart mdb-api
pm2 restart mdb-web

To also update environment variables, you need to add the --update-env

Clone this wiki locally