惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

V
Visual Studio Blog
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
N
Netflix TechBlog - Medium
博客园 - 叶小钗
大猫的无限游戏
大猫的无限游戏
S
SegmentFault 最新的问题
V
V2EX
IT之家
IT之家
J
Java Code Geeks
Hacker News - Newest:
Hacker News - Newest: "LLM"
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
GbyAI
GbyAI
D
Docker
S
Secure Thoughts
Recent Announcements
Recent Announcements
Webroot Blog
Webroot Blog
Application and Cybersecurity Blog
Application and Cybersecurity Blog
云风的 BLOG
云风的 BLOG
博客园_首页
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Security Archives - TechRepublic
Security Archives - TechRepublic
酷 壳 – CoolShell
酷 壳 – CoolShell
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
N
News | PayPal Newsroom
S
Security @ Cisco Blogs
I
InfoQ
Last Week in AI
Last Week in AI
SecWiki News
SecWiki News
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
W
WeLiveSecurity
T
Troy Hunt's Blog
Recent Commits to openclaw:main
Recent Commits to openclaw:main
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Attack and Defense Labs
Attack and Defense Labs
美团技术团队
T
The Blog of Author Tim Ferriss
Google DeepMind News
Google DeepMind News
Martin Fowler
Martin Fowler
B
Blog
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Scott Helme
Scott Helme
T
Tor Project blog
Know Your Adversary
Know Your Adversary
有赞技术团队
有赞技术团队
Hugging Face - Blog
Hugging Face - Blog
Recorded Future
Recorded Future
C
Cyber Attacks, Cyber Crime and Cyber Security
AI
AI
G
Google Developers Blog

博客园 - royalrover

How LLMs Actually Work(翻译) 微调LLM前你需要了解的一些概念-- 反向传播解析 微调LLM前你需要了解的一些概念-- 基于 Qwen3 配置文件的实践 微调LLM前你需要了解的一些概念2--多头注意力机制 微调LLM前你需要了解的一些概念1 -- 综述 从控制论看 Harness Engineering:当反馈回路终于能在"重要的地方"闭合 快速搭建你的数据智能分析 Agent 5分钟Mac本地跑通32B Qwen!免费GPT-4o替代,还能5分钟造个会开浏览器+执行Shell的AI Agent 深入剖析 nanobot:轻量级 AI Agent 框架的架构之道 k8s上手 iOS MDM(监管锁)入门 SRE中的SLA/SLO/SLI 开放网关统一认证服务 业务网关之AK中心建设 Feature Police导致iframe页面无法使用粘贴功能 页面异步请求canceled 或 network中接口请求成功但无法查看返回值 我在阿里云做云开发平台 阿里云云开发平台助力企业Serverless架构升级实战 随心一笔 nodejs中的并发编程 基于Unix Socket的可靠Node.js HTTP代理实现(支持WebSocket协议) nginx(tengine)访问日志分片 serverless在微店node领域的探索应用 node应用远程调试教程 Node EE方案 -- Rockerjs在微店的建设与发展
cluster模块设置子进程的stdio - royalrover - 博客园
royalrover · 2019-12-11 · via 博客园 - royalrover

原因

子进程的stdout及stderr需要被设置为某个文件,根据文档 setupMaster 说明,需要设置stdio数组:

c.setupMaster({
        exec: `${cwd}/c.js`,
        stdio: [0, 1, 2, 'ipc']
})

其中,stdio中的项可以为数组。

小问题

master.js

let c = require('cluster');
let fs = require('fs');
let path = require('path');
let cwd = process.cwd();

let o = fs.createWriteStream(path.join(cwd, 'out.log'));
c.setupMaster({
        exec: `${cwd}/c.js`,
        stdio: [0, o, o, 'ipc']
})
    
c.fork();

c.js

console.log(13324)
console.error('error')

如果直接这样使用,则会抛错

throw new errors.TypeError('ERR_INVALID_OPT_VALUE', 'stdio',
      ^
TypeError [ERR_INVALID_OPT_VALUE]: The value "WriteStream"

原因是stdio中的stream对象还未准备好,因此需要提前创建流。
如下:

let c = require('cluster');
let fs = require('fs');
let path = require('path');
let cwd = process.cwd();

let o = fs.createWriteStream(path.join(cwd, 'out.log'));

setTimeout(() => {
    c.setupMaster({
        exec: `${cwd}/c.js`,
        stdio: [0, o, o, 'ipc']
    })
    
    c.fork();
},10)