摘要: nodejs读写redis https://redis.io/commands https://www.npmjs.com/package/redis var redis = require('redis'); var client = redis.createClient(); client.on 阅读全文
posted @ 2020-07-06 10:44 iTech 阅读(371) 评论(0) 推荐(0) 编辑
摘要: nodejs队列 创建具有指定并发性的队列对象。添加到队列的任务以并行方式处理(直到并发性限制)。如果所有的worker都在进行中,任务就会排队,直到有一个worker可用。worker完成任务后,将调用该任务的回调。 priorityQueue对象,queue和priorityQueue对象有两个 阅读全文
posted @ 2020-07-06 10:27 iTech 阅读(3096) 评论(0) 推荐(0) 编辑
摘要: nodejs集群 单个 Node.js 实例运行在单个线程中。 为了充分利用多核系统,有时需要启用一组 Node.js 进程去处理负载任务。 集群中的Master 现在让我们详细了解Master的职责。 Fork/Spawn Worker: Master负责创建你需要的Worker进程,但是你不能创 阅读全文
posted @ 2020-07-06 10:24 iTech 阅读(825) 评论(0) 推荐(0) 编辑
摘要: shelljs https://github.com/shelljs/shelljs 实例 var shell = require('shelljs'); if (!shell.which('git')) { shell.echo('Sorry, this script requires git') 阅读全文
posted @ 2020-07-06 10:18 iTech 阅读(2565) 评论(0) 推荐(0) 编辑
摘要: websockets介绍 websockets这个新协议为客户端提供了一个更快、更有效的通信线路。像HTTP一样,websockets运行在TCP连接之上,但是它们更快,因为我们不必每次都打开一个新的连接来发送消息,因为只要服务器或客户端想要,连接就会一直保持活跃。 更好的是,由于连接永远不会中断, 阅读全文
posted @ 2020-07-06 10:13 iTech 阅读(569) 评论(0) 推荐(0) 编辑
摘要: http相关modules HTTP – the Standard Library Request Axios SuperAgent 推荐使用axios 或者super agent 使用axios和superagent的get const axios = require('axios'); axio 阅读全文
posted @ 2020-07-06 09:57 iTech 阅读(4930) 评论(0) 推荐(0) 编辑
摘要: 获取进程相关的基本信息 #!/bin/env node console.log (process.execPath) console.log (process.cwd()) console.log (process.pid) let user = process.env.USER || "" con 阅读全文
posted @ 2020-07-06 09:50 iTech 阅读(1283) 评论(0) 推荐(0) 编辑
摘要: nodejs读写yaml npm install -g js-yaml // read.js const fs = require('fs'); const yaml = require('js-yaml'); try { let fileContents = fs.readFileSync('./ 阅读全文
posted @ 2020-07-06 09:38 iTech 阅读(2984) 评论(0) 推荐(1) 编辑