Today, I took the time to browse node.js, haha, and read an introductory article (http://www.nodebeginner.org/index-zh-cn.html). I feel like I'm getting started, but there is a sentence in it that makes me feel very insightful:
The code copy is as follows:
However, these are all front-end technologies after all. Although using jQuery always makes you feel good when you want to enhance your page, in the end, you are at most a JavaScript user, not a JavaScript developer. Then, Node.js, JavaScript on the server, how cool is this? So, you feel it's time to pick up the familiar and unfamiliar JavaScript again. But don't worry, writing Node.js applications is a thing; understanding why they need to be written in the way they write means that you need to understand JavaScript. This time I played it real.
Yep, I'm going to play it this time. .
By the way, seeing a good thing log.io, the official explanation is:
The code copy is as follows:
Real-time log monitoring in your browser
Powered by node.js + socket.io
For real-time log monitoring, we may think that tail -f , log.io under Linux also has roughly this meaning, but it is much stronger than tail -f. This thing is also based on the C/S architecture.
Here is a practical demonstration:
1. Installation
This thing depends on nodejs. Let's install nodejs first, refer to the official installation method: (http://nodejs.org/download/)
I'm using brew installation method of mac here:
The code copy is as follows:
brew install nodejs
Or use yum:
The code copy is as follows:
yum install nodejs
After that, we can use npm to install log.io
The code copy is as follows:
npm install -g log.io --user "chenqing"
After installation, start the server (no configuration required):
The code copy is as follows:
log.io-server
Configure the client later
The code copy is as follows:
vim ~/.log.io/harvester.conf
exports.config = {
nodeName: "application_server",
logStreams: {
test: [
"/Users/chenqing/test.log"
]
},
server: {
host: '0.0.0.0',
port: 28777
}
}
Start the client: log.io-harvester
Let's test it:
First, on the command line
The code copy is as follows:
[ chenqing@Qing ~ ] for i in {1..1000};do echo `date ` >> test.log ;done
Open the browser: http://localhost:28778/