More logs around 'sendFile'
This commit is contained in:
parent
ef882846f2
commit
41541c2ffd
@ -30,7 +30,11 @@ MainFallback.prototype.getNextQuery = function (job) {
|
||||
|
||||
MainFallback.prototype.getOnSuccess = function (job) {
|
||||
if (job.status === jobStatus.DONE && job.fallback_status === jobStatus.PENDING) {
|
||||
return job.query.onsuccess;
|
||||
var onsuccessQuery = job.query.onsuccess;
|
||||
if (onsuccessQuery) {
|
||||
onsuccessQuery = onsuccessQuery.replace(/<%=\s*job_id\s*%>/g, job.job_id);
|
||||
}
|
||||
return onsuccessQuery;
|
||||
}
|
||||
};
|
||||
|
||||
@ -40,7 +44,12 @@ MainFallback.prototype.hasOnSuccess = function (job) {
|
||||
|
||||
MainFallback.prototype.getOnError = function (job) {
|
||||
if (job.status === jobStatus.FAILED && job.fallback_status === jobStatus.PENDING) {
|
||||
return job.query.onerror;
|
||||
var onerrorQuery = job.query.onerror;
|
||||
if (onerrorQuery) {
|
||||
onerrorQuery = onerrorQuery.replace(/<%=\s*job_id\s*%>/g, job.job_id);
|
||||
onerrorQuery = onerrorQuery.replace(/<%=\s*error_message\s*%>/g, job.failed_reason);
|
||||
}
|
||||
return onerrorQuery;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -275,13 +275,20 @@ OgrFormat.prototype.sendResponse = function (opts, callback) {
|
||||
var nextPipe = function (finish) {
|
||||
logger.info({ custom: true, size: baking.req.length }, 'Sending responses');
|
||||
var r = baking.req.shift();
|
||||
if (!r) { finish(null); return; }
|
||||
logger.info({ custom: true, size: baking.req.length }, 'Request shifted');
|
||||
if (!r) {
|
||||
logger.info({ custom: true, size: baking.req.length }, 'There is no request');
|
||||
finish(null);
|
||||
return;
|
||||
}
|
||||
logger.info({ custom: true, size: baking.req.length }, 'Sending file');
|
||||
r.sendFile(err, dumpfile, function () {
|
||||
nextPipe(finish);
|
||||
});
|
||||
};
|
||||
|
||||
if (!err) {
|
||||
logger.info({ custom: true }, 'Next pipe');
|
||||
nextPipe(this);
|
||||
} else {
|
||||
_.each(baking.req, function (r) {
|
||||
@ -330,11 +337,13 @@ function ExportRequest (ostream, callback, beforeSink) {
|
||||
|
||||
ExportRequest.prototype.sendFile = function (err, filename, callback) {
|
||||
if (err) {
|
||||
logger.info({ custom: true }, 'There is an error sending file');
|
||||
return callback(err);
|
||||
}
|
||||
|
||||
var that = this;
|
||||
if (!this.canceled) {
|
||||
logger.info({ custom: true }, 'Not cancelled (sending file)');
|
||||
this.istream = fs.createReadStream(filename)
|
||||
.on('open', function (/* fd */) {
|
||||
if (that.beforeSink) {
|
||||
@ -343,21 +352,25 @@ ExportRequest.prototype.sendFile = function (err, filename, callback) {
|
||||
that.istream
|
||||
.pipe(that.ostream)
|
||||
.on('end', () => {
|
||||
logger.info({ custom: true }, 'Sending file: on open end');
|
||||
callback();
|
||||
that.cb();
|
||||
})
|
||||
.on('error', (err) => {
|
||||
logger.info({ custom: true }, 'Sending file: on open error');
|
||||
callback();
|
||||
that.cb(err);
|
||||
});
|
||||
})
|
||||
.on('error', function (e) {
|
||||
logger.info({ custom: true }, 'Sending file: on error');
|
||||
console.log("Can't send response: " + e);
|
||||
that.ostream.end();
|
||||
that.cb(e);
|
||||
callback();
|
||||
})
|
||||
.on('end', () => {
|
||||
logger.info({ custom: true }, 'Sending file: on end');
|
||||
that.cb();
|
||||
callback();
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user