2016-12-07 23:12:00来自分类 NodeJS
# 1. 安装 pm2 ```bash npm install pm2 -g ``` # 2. 写启动脚本 ```bash # vi ~/ecosystem.json ``` ```json { "apps" : [{ // Application #1 "name" : "api", "script" : "server.js", "merge_logs" : true, "cwd" : "/home/web/mmf-blog-api", "env": { "NODE_ENV": "development", "AWESOME_SERVICE_API_TOKEN": "xxx" }, "env_production" : { "NODE_ENV": "production" }, "exec_mode" : "cluster_mode", "log_date_format": "YYYY-MM-DD HH:m...
2016-12-07 22:12:00来自分类 NodeJS
# 1. 安装 ```bash npm install request --save-dev npm install socks5-http-client ``` # 2. 代码 ```javascript var request = require('request') var Agent = require('socks5-http-client/lib/Agent') var request_option = { url: 'http://www.google.com', agentClass: Agent, agentOptions: { socksHost: '127.0.0.1', socksPort: 1080 } } node.request(request_option, (err, res, body) => { // balabala }) ```...
2016-12-07 22:12:00来自分类 NodeJS
# Model.save 基于 entity 操作 ```javascript var doc = {username : 'model_demo_username', title : 'model_demo_title', content : 'model_demo_content'}; var Entity = new Model(doc); Entity.save(doc, function(error) { // do something }); ``` # Model.create 基于 model 操作 ```javascript var doc = {username : 'model_demo_username', title : 'model_demo_title', content : 'model_demo_content'}; Model.create(doc, function(error) { // do something }); ``` # Model.find ```javascript Model.find(query, fiel...