Open markbrinkman opened 1 year ago
I also encountered this error when using "child_process": write EPIPE. The functions I call are "child_process.spawn" and "child_process.exec". There are no errors running the program directly using "node main.js".
Please, have you solved this problem?
any help, please!I encountered the same error after my cron job start two days ,and it seems running well after restart;and again, it crash with the error after about two days.
2023-06-18T14:01:11: PM2 error: Error: write EPIPE
at ChildProcess.target._send (internal/child_process.js:839:20)
at ChildProcess.target.send (internal/child_process.js:710:19)
at God.sendDataToProcessId (/usr/lib/node_modules/pm2/lib/God/ActionMethods.js:720:12)
at Server.onmessage (/usr/lib/node_modules/pm2/node_modules/pm2-axon-rpc/lib/server.js:104:6)
at RepSocket.emit (events.js:376:20)
at RepSocket.emit (domain.js:470:12)
at Parser.
any help, please!I encountered the same error after my cron job start two days ,and it seems running well after restart;and again, it crash with the error after about two days.
兄弟,这个问题我解决了,先说一下我的程序。 我的操作系统是Linux,程序使用child_process的exec执行goaccess命令(goaccess是一个Nginx日志分析工具),大概命令是:
cat xxx.log | goaccess xxx
当我在dev模式下运行程序时,一切正常;当我使用PM2运行程序时,会报此错误:write EPIPE error 我在好多网站上查找了好久,费了好大力气,才意外的发现这个问题跟goaccess有关,当我使用PM2运行程序时,goaccess并不知道数据会从pipe管道输入,所以报了这个错。 我查找了goaccess的issue,作者提供了一个标识符,可以告诉goaccess数据是从pipe管道输入的,当我把命令改成这样,程序就正常运行了:
cat xxx.log | goaccess xxx -
注意,比之前的命令多了个“-”,这就是goaccess管道输入的标识符。
我的问题就这样解决了,希望能帮到你。
The following is the English translation of ChatGPT:
Brother, I solved this problem. Let me first explain my program. My operating system is Linux, and the program uses the exec function of child_process to execute the goaccess command (which is an Nginx log analysis tool). The command is roughly as follows:
cat xxx.log | goaccess xxx
When I run the program in dev mode, everything is normal. But when I use PM2 to run the program, it reports an error: write EPIPE error. I searched many websites for a long time and finally found out that this problem is related to goaccess. When I use PM2 to run the program, goaccess does not know that data will be input from the pipe, so it reports this error. I searched the goaccess issue tracker and found that the author provided an identifier that can tell goaccess that data is being input from a pipe. When I changed the command to the following, the program ran normally:
cat xxx.log | goaccess xxx -
Note that there is an extra hyphen compared to the previous command, which is the identifier for goaccess to indicate that data is being piped in. That's how I solved my problem. I hope it can help you.
What's going wrong?
Last night our pm2 randomly stopped running after two weeks without any problems. After running
pm2 resurrect
the process restarted without any issues. When searching through the logs i found the following errors:How could we reproduce this issue?
I am not quite sure how to produce/avoid this issue.
Supporting information