Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Upgraded to latest mysql client version to fix hang, better logging

  • Loading branch information...
commit b414499a6fbd335e771ee0c9f20890b20c8e694c 1 parent d9edb3a
@jhurliman authored
Showing with 10 additions and 3 deletions.
  1. +3 −1 controllers/fingerprinter.js
  2. +6 −1 models/mysql.js
  3. +1 −1  package.json
View
4 controllers/fingerprinter.js
@@ -316,7 +316,7 @@ function ingest(fp, callback) {
return callback('Missing or invalid "track" field', null);
if (!fp.artist)
return callback('Missing or invalid "artist" field', null);
-
+
fp = cutFPLength(fp, MAX_DURATION);
// Acquire a lock while modifying the database
@@ -419,6 +419,7 @@ function ingest(fp, callback) {
// Function for creating a new artist and new track
function createArtistAndTrack() {
+ log.debug('Adding artist "' + fp.artist + '"')
database.addArtist(fp.artist, function(err, artistID) {
if (err) { gMutex.release(); return callback(err, null); }
@@ -430,6 +431,7 @@ function ingest(fp, callback) {
// Function for creating a new track given an artistID
function createTrack(artistID, artist) {
+ log.debug('Adding track "' + fp.track + '" for artist "' + artist + '" (' + artistID + ')');
database.addTrack(artistID, fp, function(err, trackID) {
if (err) { gMutex.release(); return callback(err, null); }
View
7 models/mysql.js
@@ -6,6 +6,7 @@
var fs = require('fs');
var mysql = require('mysql');
var temp = require('temp');
+var log = require('winston');
var config = require('../config');
exports.fpQuery = fpQuery;
@@ -20,12 +21,13 @@ exports.updateArtist = updateArtist;
exports.disconnect = disconnect;
// Initialize the MySQL connection
-var client = mysql.createClient({
+var client = mysql.createConnection({
user: config.db_user,
password: config.db_pass,
database: config.db_database,
host: config.db_host
});
+client.connect();
/**
*
@@ -166,13 +168,16 @@ function addTrack(artistID, fp, callback) {
tempName = '/tmp/' + require('path').basename(tempName);
// Write out the codes to a file for bulk insertion into MySQL
+ log.debug('Writing ' + fp.codes.length + ' codes to temporary file ' + tempName);
writeCodesToFile(tempName, fp, trackID, function(err) {
if (err) return callback(err, null);
// Bulk insert the codes
+ log.debug('Bulk inserting ' + fp.codes.length + ' codes for track ' + trackID);
sql = 'LOAD DATA LOCAL INFILE ? IGNORE INTO TABLE codes';
client.query(sql, [tempName], function(err, info) {
// Remove the temporary file
+ log.debug('Removing temporary file ' + tempName);
fs.unlink(tempName, function(err2) {
if (!err) err = err2;
callback(err, trackID);
View
2  package.json
@@ -2,7 +2,7 @@
"name": "echoprint-server",
"version": "0.1.0",
"dependencies": {
- "mysql": "0.9.6",
+ "mysql": "2.0.0-alpha8",
"winston": "0.6.2",
"jade": "0.28.2",
"async": "0.2.6",
Please sign in to comment.
Something went wrong with that request. Please try again.