Node.js upstart vs forever

安稳与你 提交于 2019-12-20 09:57:51

问题


I am looking to daemonize my Node.js application. What's the difference between upstart and forever? Also, are there other packages I might want to considering looking at?


回答1:


As pointed out in the comments, upstart will be used to start the forever script, since upstart has hooks for system events (like shutdown and startup of your server).

The other differences are:

  • Upstart was developed for Linux, while forever is platform-independent.
  • Forever is specific to nodejs, and has some pretty cool features with regards to restarting your server after it crashes, and logging.
  • Forever is sufficient for development environment, while upstart is necessary if you need to have some control over how your server is stopped. For example, on shutdown, the forever process would simply get killed, but, with an upstart script, you can collect logs and notify the admin.
  • Upstart allows you to add other monitoring tools, like Monit.

Among the available other solutions, you can try daemon, which is equivalent to forever.

I would disagree with @leorex with regards to upstart setup. Check out this blog post for an excellent example.




回答2:


upstart is a general utility for daemonizing an application. Forever is designed for Node.js. For most purposes, forever is better for Node.js applications as it is simpler, tuned towards node.js and easy to configure. Just try a few tutorials on upstart and you will agree with me.




回答3:


The main difference in objective is that upstart is designed to start an application on system boot. Forever doesn't have that and instead is focused on keeping a node.js script running despite crashes (most likely unhandled exceptions). You will be wise to combine the two .. i.e. start forever yourscript.js from upstart (on system boot).

That said you will need to look at your platform specific version of upstart equivalent. Upstart was never on windows and is now deprecated for ubuntu / debian : http://www.markshuttleworth.com/archives/1316




回答4:


In 2017, alternatives could be :

  • pm2. Robust, strong community, production-grade solution. Can manage non-node scripts as well. My personal choice.
  • StrongLoop (slc). Node-only. Production-oriented as well, includes build/packaging, deployment to docker, load-balancing and profiling, but is more recent. Looks promising.

Here is a (maybe biased) comparison of both with Forever.



来源:https://stackoverflow.com/questions/20601399/node-js-upstart-vs-forever

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!