Daemonizing Applications With Pm2: A Step-By-Step Guide

PM2
daemonizing applications
unbuffered output
installation
configuration
monitoring
monit
This article provides a comprehensive guide on how to daemonize applications with PM2. It covers the process of setting up unbuffered output, installing and configuring PM2, running processes as daemons, and monitoring them using monit.
Published

July 8, 2024


PM2 daemonize any app

remember to set unbuffered output flag -u before running any python script, otherwise there will be no output in pm2 log


install and setup pm2 as daemon:

sudo apt install npm
sudo npm config set registry https://registry.npmmirror.com
sudo npm install -g pm2
pm2 startup

run program as daemon:

pm2 start -n <process_name> <executable_name> -- <process_arguments>
# save all processes
pm2 save
pm2 monit
pm2 logs
pm2 ls