se insert restituisce errore di chiave duplicata, continua
This commit is contained in:
parent
4178fbd2ae
commit
e58b40c296
1 changed files with 12 additions and 6 deletions
|
@ -128,11 +128,17 @@ MongoClient.connect(mongoUri, function(err, db){
|
|||
ip: slog[2],
|
||||
}, function(err, r){
|
||||
if( err ){
|
||||
console.log(err);
|
||||
if ( err.errmsg.indexOf("duplicate key error") >= 0 ) {
|
||||
logger.log("Duplicate key: %s - ", log, user, lindex);
|
||||
readLogs(lindex+1, user, len);
|
||||
}else {
|
||||
logger.log("insert error: %s", err);
|
||||
redis.rpush(user, log, function(err, result){
|
||||
quit();
|
||||
process.exit(-4);
|
||||
});
|
||||
}
|
||||
} else {
|
||||
// Salvato il log su mongo, legge il successivo.
|
||||
logger.log("Saved: %s - ", log, user, lindex);
|
||||
|
|
Loading…
Add table
Reference in a new issue