문제

During development it would be great to have node.js restarted automatically when changes occur in the applications directory. When the application is in production, node could be start just like normally. When the server is rebooted with or without intention, node needs obviously to be restarted.

I've heard about and tried both forever and supervisor. Supervisor works good, but I can't make it to start during boot. Forever on the other hand ignores any changes in my directory.

Are there alternatives that are available that would do all this for me?

Thanks

도움이 되었습니까?

해결책

Here's what I ended up doing:

Below code was put 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

Always checks for changes in my node directory while this script ensures that always is started on boot.

다른 팁

I've recently started using Foreman to manage my apps. You can export from Foreman to Upstart which should solve your problem with handling reboots, etc. in a production environment (although I haven't done this myself yet.)

For automatically updating files on change, check out always. (Then run always from your local Procfile through Foreman - that's my setup.)

I don't think you are likely to find anything that automatically starts node on boot, but depending on your OS, this isn't very difficult. Could you tell us what your OS is?

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top