在fs.writeFile()之后,Heroku使用SIGTERM停止进程

时间:2018-09-07 17:38:29

标签: node.js heroku deployment

我有一个server部署到Heroku。在执行git push heroku master之后,我会在服务器启动时立即查找日志。在让服务器侦听端口3000之后,立即调用fs.writeFile()写入文件,然后在回调中记录数据已保存。不久之后,我收到警告Stopping all processes with SIGTERM

我读到Heroku不鼓励写入文件,并且通过写入文件生成的文件都是短暂的...但是我已经推送了一个实际的空data.json文件供服务器写入。我不确定写入文件是否会导致服务器崩溃?还有什么可能导致此问题?

2018-09-07T17:23:43.000000+00:00 app[api]: Build succeeded
2018-09-07T17:23:45.278811+00:00 heroku[web.1]: Starting process with command `npm start`
2018-09-07T17:23:47.048087+00:00 app[web.1]:
2018-09-07T17:23:47.048115+00:00 app[web.1]: > typeform-messenger-server@1.0.0 start /app
2018-09-07T17:23:47.048117+00:00 app[web.1]: > node server/index.js
2018-09-07T17:23:47.048119+00:00 app[web.1]:
2018-09-07T17:23:47.526591+00:00 app[web.1]: koa app listening on port 3000
2018-09-07T17:23:47.607097+00:00 app[web.1]: The form has been saved!
2018-09-07T17:24:31.494341+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2018-09-07T17:24:31.727568+00:00 heroku[web.1]: Process exited with status 143
2018-09-07T17:24:45.723565+00:00 app[web.1]: Error waiting for process to terminate: No child processes
2018-09-07T17:24:45.701555+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2018-09-07T17:24:45.701664+00:00 heroku[web.1]: Stopping process with SIGKILL
2018-09-07T17:24:45.777357+00:00 heroku[web.1]: Process exited with status 22
2018-09-07T17:24:45.812422+00:00 heroku[web.1]: State changed from starting to crashed

0 个答案:

没有答案