Saving node.js

During development, it would be great that node.js will restart automatically when changes happen in the application directory. When the application is in production, node can be started in the same way as usual. When the server restarts with or without intent, node needs to restart.

I have heard and tried both forever and supervisor . The supervisor works well, but I cannot get it to start at boot time. Forever, on the other hand, ignores any changes to my directory.

Are there alternatives that will do all this for me?

thanks

+6
source share
3 answers

Here is what I ended up doing:

Below code has been placed in /etc/init/myApplication.conf :

 # Enter below respawn console none start on runlevel [2345] stop on runlevel [06] script sudo always /var/www/backend/app.js > /var/www/backend/nodelog.log end script 

It always checks for changes in my node directory, while this script ensures that it always runs at boot time.

+5
source

I recently started using Foreman to manage my applications. You can export from Foreman to Upstart , which should solve your problem with reboot handling, etc. In a production environment (although I haven't done it yet.)

To automatically update files when changing, always . (Then always start from your local Procfile through Foreman - this is my setup.)

+3
source

I don’t think that you will probably find something that node starts automatically when it boots, but depending on your OS it is not very difficult. Could you tell us what your OS is?

+1
source

Source: https://habr.com/ru/post/906135/


All Articles