Run at the beginning a script developed with nodejs in ubuntu server 16?

2

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?

    
asked by Wuilmer Medrano 27.01.2017 в 20:14
source

1 answer

1

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.

    
answered by 28.01.2017 в 13:58