Hi everyone, i'm facing with issue that my nightmare project is keeping electron threads everytime cronjob call. Currently, i workaround by kill threads that exist more than 2 min. My question is that there is anyway to fix it ??
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);
}
Here my RAM usage and threads: