Node.js deployment stack

六月ゝ 毕业季﹏ 提交于 2019-12-12 10:58:29

问题


What is the best node.js deployment stack? I'm going to use Nginx comunicating with node.js on fugue through unix domain socket + mongodb + NPM packages installed in user home. Is there something better?

By the way, shouldn't node have something like rack, which would handle server configuration and start listening on port or socket which would be forced by server software? Now I do crazy hi-jacking server.listen function to get server and launch it by fugue. Have You some experience on doing drop-in node deployment?


回答1:


There are are a few projects under development aimed at solving this problem:

forever and cluster (video intro for cluster) are both pretty good solutions. I've noticed small discrepancies in both when I tried them -- meaning that they may not have the problems anymore.

There are 2 main things you need to consider when choosing a deployment:

  1. daemonizing the node app
  2. restarting the node app if it crashes

you may also want to consider logging, command line features, and security. You could also pretty much just write your own implementation script that uses nohup.

One last thing that I don't know how to deal with yet: security. Last I checked you can't really use SSL in a stable way unless you use something like nginx, and I don't know about security holes in node either.




回答2:


Disclaimer: Not a node expert

I believe Connect is considered a Rack analogue.

Note that SSL support in Node is, according to its creator, largely broken and a work-in-progress, so if your app needs SSL support--and what professional app doesn't?--you'll need to run Node in cooperation with another component, typically nginx AFAIK.

I recommend watching the mailing list for developments in this area and information about common configurations.




回答3:


Most Node.js deployments I've seen serves directly from the javascript code itself using http.createServer. In other words, most node.js scripts I've seen are web servers rather than just web apps. Several frameworks written for Node.js sort of assumes this.

That's part of the whole point of Node.js - serve your content using a non-blocking, single-threaded, event-driven server.




回答4:


for a more boilerplate install you can try the mean stack. i've had good experiences with express (http://expressjs.com) and mongo (http://mongodb.com). here is a page with a quick install guide for mean stack: http://mean.io

of course you can simply use forever or upstart as mentioned above: http://jacobmumm.com/2011/08/29/node-as-a-service-in-ubuntu-11-04-with-upstart-monit-and-forever-js/



来源:https://stackoverflow.com/questions/4589838/node-js-deployment-stack

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