Hi, I have a backend in amazon aws. Developed with nodejs, and it is necessary to execute that script in what the system starts. How could I do that?
Hi, I have a backend in amazon aws. Developed with nodejs, and it is necessary to execute that script in what the system starts. How could I do that?
The package pm2 is simply excellent. It has many commands that you can use to get information or perform actions at a lower level.
pm2
what it does is first detect init.d . In this directory, on UNIX systems, there are many scripts to control system services, so these scripts recognize commands such as start , stop , among others.
The app
command packages the Node.js application as a daemon (this can be seen in the logs), generating a PUID and everything necessary to manage it. You can see how he does it by reading the source code .
pm2 start app.js // app.js es el entry point de la aplicación
There are more options like node-startup or do it directly by creating a configuration file in etc / init , but if you are in production, pm2
is the most recommended.