Node.js crashing
Problem
My node.js app keeps crashing. It's a simple web service that gets data from a mysql database. I get about 20k to 30k queries a day. I'm not sure if it's crashing because I need to give it more resources or if I have a problem with my code. It's hosted in AppFog and here's the crashlog.
I'm not sure what the hashish package is but I tried installing it using 'npm install hashish' and it didn't fix the problem.
Any thoughts?
C:\Users\Tom\\nodejs>af crashlogs TomsApp
====> /logs/staging.log /logs/stderr.log
Related Articles
Solution
How are you getting your connection? Do you get it once, or get a new one for each request and then return it to the pool? The pool should be handling stale connections behind the scene.
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();
});
Discussion
View additional discussion.