我面临着一个问题,我的噩梦计划每次cronjob都在保持电子线程。目前,我通过杀死存在2分钟以上的线程来解决。我的问题是无论如何都可以解决它?
var nightmare2 = new Nightmare({
})
nightmare2
.goto(url)
.wait(3000)
.wait('body')
.evaluate(() => document.querySelector('body').innerHTML)
.end()
.then(response => {
console.log(get_body(response));
}).catch(err => {
fs.unlinkSync('./lock.txt');
console.log('Lock file deleted')
console.log(err);
});
let get_body = body_content => {
crawled_object = crawl_preview(pledge_money, backers, total_money, body_content);
}
var nightmare3 = new Nightmare({
})
nightmare3
.goto(login_url)
.type("input[name='user_session[email]']", '')
.wait(100)
.type("input[name='user_session[email]']", login_payload.user_session_email)
.wait(100)
.type("input[name='user_session[password]']", '')
.wait(100)
.type("input[name='user_session[password]']", login_payload.user_session_password)
.wait(100)
.click("input[type='submit']")
.wait(2000)
.goto(edit_url)
.wait(4000)
.wait('body')
.evaluate(() => document.querySelector('body').innerHTML)
.then(response => {
console.log(get_pledge_body(response));
}).catch(err => {
fs.unlinkSync('./lock.txt');
console.log('Lock file deleted')
console.log(err);
});
let get_pledge_body = body_content => {
var $ = cheerio.load(body_content);
//get number of rewards in project
reward_length = $("div[id='app'] > div:nth-child(n+3) > div:nth-child(n+1) > div:nth-child(n+2) \
> div:nth-child(n+1) > div > div").length - 4;
console.log("reward_length before change " + reward_length);
console.log(crawled_object)
console.log(name)
console.log("Change list is: ")
console.log(change_list)
change_pledge(crawled_object, reward_length);
}
这是gnome系统监视器提供的我的线程列表: thread list