我们在 S1 托管计划下有一个 Azure 网站,运行 Node 应用程序并连接到 DocumentDB。每次我们尝试将媒体上传到 DocumentDB 时,node.exe 进程都会崩溃并重新启动。附件的大小似乎无关紧要。在 Mac 上本地运行时,我没有在 iisnode 容器中运行,只是在直接节点中运行,所以它不是我能够在我的受控环境中重现的东西。这实质上会导致应用程序看起来冻结或始终重定向到登录页面。这是代码(我使用的是 1.0.3 vs docdb nodejs sdk):
应用程序.js
app.post('/portal/add/media',isAuthenticated,
[ multer({ dest: './uploads/'}), portalCrud.addMedia.bind(portalCrud)]);
portalCrud.js
addMedia: function (req, res) {
var self = this;
var file = req.files.attachment;
var errorCallback = function(error) {
console.log("Document updated with media ERROR..." + error);
res.status(error.status || 500);
res.render('error', {
message: error.message,
error: error
});
};
var readableStream = fs.createReadStream(file.path);
readableStream.on("close", function() {
fs.unlinkSync(file.path);
});
var options = {
slug: file.originalname,
contentType: file.mimetype
};
// the attachment has been added, now get the parent object to update
self.dao.getDocument(req.body.docId, false, function (gdErr, parentDocument) {
handleError(gdErr, errorCallback);
if(gdErr) return;
self.dao.addAttachment(parentDocument._self, readableStream, options, function (err, attachment) {
handleError(err, errorCallback);
if(err) return;
res.status(200).send(req.header('Referer'));
});
});
}
dao.js
addAttachment: function (docLink, readableStream, options, callback) {
var self = this;
self.client.createAttachmentAndUploadMedia(docLink, readableStream, options, function (err, resp) {
if (err) {
callback(err);
} else {
callback(null, resp);
}
});
}
我对 Azure 还是很陌生。我已经尽可能多地打开了日志记录,但没有发现任何表明存在问题的东西。似乎没有发出任何事件,我似乎无法启用或找到 iisnode 日志。d:\home\LogFiles\Application\logging-errors.txt 似乎没有记录任何内容,但我可以看到,每当我进行上传时,节点进程都会获得一个新的 PID,就像它崩溃并重新启动一样。任何人都可以提供的任何提示将不胜感激。我会提供任何我能提供帮助的信息。