gpt4 book ai didi

Node.js 崩溃

转载 作者:搜寻专家 更新时间:2023-10-31 23:55:38 35 4
gpt4 key购买 nike

我的 node.js 应用总是崩溃。这是一个从 mysql 数据库获取数据的简单 Web 服务。我每天收到大约 2 万到 3 万个查询。我不确定它是否崩溃,因为我需要给它更多的资源,或者我的代码是否有问题。它托管在 AppFog 中,这里是崩溃日志。

我不确定 hashish 包是什么,但我尝试使用“npm install hashish”安装它,但没有解决问题。

有什么想法吗?

C:\Users\Tom\\nodejs>af crashlogs TomsApp
====> /logs/staging.log <====

# Logfile created on 2013-02-05 00:53:01 +0000 by logger.rb/25413
Installing dependencies. Node version 0.8.14
Installing mysql@mysql@0.9.6 from local path
Installing hashish@hashish@0.0.4 from registry
Package is not found in npm registry hashish@hashish@0.0.4
Failed getting the requested package: hashish@hashish@0.0.4
Installing require-all@require-all@0.0.5 from local path

====> /logs/stderr.log <====


events.js:71
throw arguments[1]; // Unhandled 'error' event
^
Error: Connection lost: The server closed the connection.
at Protocol.end (/mnt/var/vcap.local/dea/apps/ta-0-365d7313671d4e40105a4d158
f1247d5/app/node_modules/mysql/lib/protocol/Protocol.js:63:13)
at Socket.onend (stream.js:66:10)
at Socket.EventEmitter.emit (events.js:126:20)
at TCP.onread (net.js:417:51)

最佳答案

您是如何建立联系的?是获取一次,还是每次请求都获取一个新的,然后放回池中?池应该在幕后处理过时的连接。

var mysql = require('mysql');
var pool = mysql.createPool({
host : 'example.org',
user : 'bob',
password : 'secret'
});


// for each request where you need the database connection, wrap it with
pool.getConnection(function(err, connection) {
// do something with connection here
...
connection.end();
});

关于Node.js 崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14714906/

35 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com