Is there a checklist there when I launch the node.js site?

I'm finishing my first site with node.js and I'm curious if there is a checklist for all the things that I need to fill out before I pick it up. In development, when certain values ​​are not expected in my database calls (using Mongoose), my site will simply die (e.g. node segfaults).

I will also use this on my VPS that already has Apache installed, so can I start both or do I need to look at something else for this?

Basically, when I do this, I want to keep it, and I would like to know about any standard precautions that I should know about before doing this.

Thanks!

+4
source share
2 answers

I'm currently in a similar situation (going to deploy my first application on a private VPS), and here is the list I came up with:

1- Error logging : here I used a simple WriteStream , nothing unusual.

var fs = require('fs'); //You might want to specify a path outside your app var file = './log.log'; var logger = fs.createWriteStream('./log.log'); app.configure(function(){ //... app.set(express.logger({stream:logger})); /... }); 

2- Use Forever to ensure that your script runs continuously. Yes, they have many other solutions (e.g. daemon ), but I have been using it forever for some time and have never had any problems.

3- Consider setting up the admin interface. This was actually a requirement in my case, so I went ahead with a smog that would look very nice, especially for your client :).

4- If you use forever, you can control its status using Monit . Check out this blog post for basic setup.

5- If you are using Mongo, consider developing a backup strategy for your data. This page is a very good starting point .


Please note that this list does not contain support information for multiple applications, multiple machines, or multi-core processors.

If you are interested in multi-app support, nginx seems like a reliable solution. This (brilliant) SO answer will help you tweak.

If you have many spare machines to use, node-http-proxy was developed by nodejitsu and allows you to expose only one machine and the reverse -proxy - the rest.

If you are looking for multi-core support, cluster comes bundled with node, so you can create N different processes (N is the number of cores you have) and ask them to listen on the common port.

And, since we all love hearing a pleasant story, here are a few posts about using nodejs / mongodb in production and lessons learned:
1- Lessons learned from i.TV launch
2- Using Mongodb for 2+ billion documents on Craigslist

+4
source

Given that Node.js is not a web server such as Apache or IIS, there is no checklist of configuration settings. In addition, given that the modules and / or frameworks you use can vary widely depending on the project you are creating, checklists will always skip something ... especially as the Node.js ecosystem continues to evolve and grow.

As such, I would suggest looking at the material here when they answer your questions and are generally useful no matter what you do with Node.js:

I am concerned that your application dies "when certain values ​​are not expected in my database calls."

Mongoose is a great tool, because it allows you to conduct selective checks of data in separate fields, it can filter out data that does not fit into the scheme you defined (matching your documents), and the correct settings can cause errors when there is "bad data" transmitted him, not sending bad data to the database and much more ...

I am wondering what you are doing, that an unhandled error causes it to skip Mongoose and go through any callback function, knowing that callbacks usually take the function(err, data) format and provide an opportunity to solve the problem immediately.

+1
source

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


All Articles