, these exceptions should be recorded in the log, and the exception will never happen again.Use node to guard nodeThe Node-forever provides the function of guarding and log logging.Very easy to install[sudo] npm install foreverIt's easy to use.$ Forever Start Simple-server.js$ Forever List[0] simple-server.js [24597, 2
Recently written program node. data storage is required for js programs. there are many databases that js can use, such as mongodb and MySQL. However, I still think these databases are too large to be useful, making them more troublesome. So I found node-tiny, a non-relational data... SyntaxHighlighter. all
Recently wr
The installation process will not be mentioned. If it succeeds, you can use the node command. Node. js debugging is very convenient. Each background language has a command to output a pragmatic command to the console Group of the Black hacker. Node.
This article mainly introduces node. fs. the truncate method is described in this article. methods, syntax, parameters, instances, and source code for truncate. For more information, see
Method description:
File Content truncation.
Syntax:
The Code is as follows:
Fs. truncate (path, len, [callback (err)])
Because this method belongs to the fs module, we need to introduce the fs module (var fs = require ("fs") before use "))
Receiving parameters:
P
user_info VALUES (NULL, 'Zhang Yi'), (NULL, 'Zhang 2'), (NULL, 'Zhang San ');
3. create a stored procedure (writing is redundant, deliberately... Just learn the syntax >_
The code is as follows:
DELIMITER $Drop procedure if exists 'test'. 'proc _ simple' $Create procedure proc_simple (IN uid INT (10), OUT uName VARCHAR (2), OUT totalCount INT)BEGIN
DECLARE str_name VARCHAR (20 );
SET @ str_name = '';SET totalCount = 0;Select count (1), userName INTO totalCount, @ str_name FROM user_info
This article mainly introduces Node. js uses the dependency injection-related issues and solutions, Node. js is a framework that runs JavaScript applications on the server. if you need JavaScript, refer to the recent introduction. I turn to dependency injection to help you understand the simple way to separate code and
This article mainly introduces the implementation of multi-process by child_process in Node. js. For more information, see
The Code is as follows:
Var http = require ('http ');Function fib (n ){If (n Return 1;} Else {Return fib (n-2) + fib (n-1 );}}Var server = http. createServer (function (req, res ){Var num = parseInt (req. url. substring (1), 10 );Res. writeHead (200 );Res. end (fib (num) + "\ n ");});
, it is actually a JSON object.(4) Database Design: We recommend that you consider NoSQL design and discard the design concept of relational data. In fact, NoSQL database design is profound and requires constant practice in projects.(5) User System: each database has its own administrator. You can:
The Code is as follows:
Use dbname; db. addUser ('root _ 1', 'test ');
(7) It is recommended to change the external Port
(8) start the service (this is a change in Windows and linux ):
The Code is
This article records that two requests will appear when you use node. js to request favican. ico in the project, wasting resources. After some improvement, record the process and pay attention to it later.
The Code is as follows:
Var http = require ("http ");Var server = http. createServer ();Server. on ("request", function (req, res) {5 console.
forms some of the most basic function interfaces we know, such as Create, Listen, Connect, Accept, Send, Read, and Write.
TCP/IP is just a protocol stack. like the operating mechanism of the operating system, it must be implemented in detail and provide external operation interfaces.
In fact, the TCP at the transport layer is based on the IP protocol at the network layer, while the HTTP protocol at the application layer is based on the TCP protocol at the transport layer, and the Socket itself
I believe everyone knows that in nodejs, path is a very frequently used but hateful module. Some documents are not clear enough, and some are due to platform differences of interfaces. This article will give you a detailed introduction to the path processing module path in Node. js, hoping to help you learn or use the module path. Let's take a look at it. Preface
In no
Use Javascript Generators in Node. js for details, node. jsgenerators
Generators is a collaborative program (coroutine for short: coroutine) style in Javascript. It refers to the functions that can be paused and restored during execution, this function is configured with a star symbol in functi, such as function *. Some feature keywords in the function, such as y
install node
Or:
Sudo aptitude update
Sudo aptitude install node
Node. js will be added to the sources source list in the sid library.
Sudo echo deb http://ftp.us.debian org/debian/sid main>/etc/apt/sources. list. d/sid. list
Note that after installation, you need to remove/etc/apt/sources. list. d/sid. list.
To insta
fully achieve load balancing. In cluster, I have already elaborated on it. Let's take a look at the specific implementation.
var cluster = require('cluster');var http = require('http');var numCPUs = require('os').cpus().length;if (cluster.isMaster) { console.log('[master] ' + "start master..."); for (var i = 0; i
The HTTP module is used here. Of course, it can also be replaced with the socket module. However, the cluster and the single side are confused due to this writing. Therefore, we rec
Node. js blog instance (6) message function, node. js instance
Original tutorial.
This function enables users to leave messages for articles. The messages are stored in the database.
Post. js, modify the document to be saved in Post. prototype. save as follows:
// Var post
This article describes how to install Node. JS on Amazon's one-year free plan, NPM, and OurJS Blog system ., For more information, see Debian for the Community edition. The operation commands of Debian and Ubuntu are in the same line, I am familiar with it. The following installation process is also applicable to the installation of node.
This article mainly introduces Node. js uses the dependency injection-related issues and solutions, Node. js is a framework that runs JavaScript applications on the server. If you need JavaScript, refer to the recent introduction. I turn to dependency injection to help you understand the simple way to separate code and
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.