我希望可以使用
这是否可能?代码在
node --debug app.js
运行以下脚本,并让node等待远程调试会话启动。我认为app.js
脚本在调试程序能够建立连接之前崩溃了。我正在使用一个隧道将端口5858转发到vagrant框,并且我知道这部分是有效的,因为我以前已经成功地使用了完全相同的设置。这是否可能?代码在
afterCheck(err,spam)) //spam is not defined
处崩溃,我想找出原因。var mysql = require('mysql');
var connection = mysql.createConnection({
host : 'localhost',
user : 'root',
password : '123',
database : 'kommunity',
debug: ['ComQueryPacket']
});
var akismet = require('akismet').client({ blog: 'deleted', apiKey: 'deleted' });
var selectPosts = "SELECT p.id as id, poster_ip, message, p.poster FROM topics t\
LEFT JOIN posts p on t.first_post_id = p.id WHERE poster_ip != ''";
//var spam = false;
akismet.verifyKey(function(err, verified) {
if(err) throw err;
if (verified) {
console.log('API key successfully verified.');
connection.connect();
connection.query(selectPosts, function(err, rows, fields) {
if (err) throw err;
var count = 0;
rows.forEach( function(entry) {
//console.log('foreach called with count '+count);
count++;
//console.log(entry['id']);
akismet.checkSpam({
user_ip: entry['poster_ip'],
comment_author: entry['poster'],
comment_content: entry['message']
}, afterCheck(err,spam))
});
});
}
else {
console.log('Unable to verify API key.');
}
});
var afterDelete = function (err, rows, fields) {
if (err) throw err;
console.log('deleted topic '+rows[0]);
console.log('spam');
connection.end();
}
var afterCheck = function(err, spam, entry) {
if(err) throw err;
console.log('after check called and spam is :'+spam);
var deleteQuery = "DELETE FROM topics , posts USING topics INNER JOIN posts \
WHERE topics.id=posts.topic_id AND topics.id ="
if(spam) {
console.log('spam');
console.log('entry is ' + entry);
connection.query(deleteQuery + entry.id + ';', afterDelete(err, rows, fields) );
connection.end();
} else {
console.log('Not spam');
}
}
--debug
,而不是在运行PHPStorm的客户端上运行。我尝试在服务器上使用--debug-brk
,但似乎它并没有停在我的断点处。 - codecowboy--inspect
和--inspect-brk
。这是来自 Node 的完整消息:“node --debug
和node --debug-brk
无效。请改用node --inspect
或node --inspect-brk
。” - Bruno Berisso