If you want to daemonize a script created with node.js.
For example, if you want a program like screenshot-as-a-service to reside on the server.
Let's use forever.
Monitor the life and death of the node.js script that you started, and restart it automatically if it stops.
npm install forever-g
forever start spp.js
Stop or restart a running script
forever stop
forever stopall
forever restart
How about creating a unit file for systemd
(although I'm not familiar with node.js)?
I think it's better to manage it using pm2.The reason is that Node.js supports clustering mode or not at the language level, so I think it would be appropriate to use pm2 as a framework to absorb it.
I don't think the pm2 process itself is likely to die if left alone, but if we do our best, I think it would be better to daemonize pm2 itself at the OS level with systemd, as Hayao Yamada said.
© 2024 OneMinuteCode. All rights reserved.