Setting up a LaunchDaemon with pm2
If you have a Node.js app running on an OS X server, you probably:
- Want it to start automatically when the system boots
- Want to use something like pm2 or forever to monitor the status of the app, log errors, and make sure it stays up
While pm2 has the ability to generate startup scripts for use with Ubunutu, Centos, and systemd, it does not work with OS X. The best approach is to use launchd, an OS X-specific daemon manager that replaces
cron. It uses XML-based files for configuration. This guide will walk you through the process. Note: "xyz" is used as a placeholder for the application name throughout this guide.